While DynamoDB doesn't preserve the insert records order, we can sort the message records by the timestamp of its creation and create
a rule for sorting them inside the DynamoDB to preserve the delivery FIFO order.
Linear task: ENG-1027
Differential D3805
[services] Tunnelbroker - Add `createdAt` timestamp to the `messageItem` • max on Apr 21 2022, 5:00 AM. Authored by Tags None Referenced Files
Details While DynamoDB doesn't preserve the insert records order, we can sort the message records by the timestamp of its creation and create Linear task: ENG-1027 Passed test at D3806.
Diff Detail
Event TimelineComment Actions Can't we just sort by message id? Is there a reason to avoid that? Could two different messages have the same timestamp? Comment Actions We use UUID-based messageID on the randomly generated string because the messageID must be unique - we will remove the delivered message by the unique id. Comment Actions Ok, that makes sense. But I'm not sure if this will work when there are multiple instances of the service. Do we need the clocks to be closely synchronized? Or maybe, we don't need to keep an order of messages handled by different instances? Overall, this looks ok, but adding @ashoat to get his opinion Comment Actions Adding more context here: Comment Actions This makes sense to me.
Ideally, yes. But it's not the end of the world if they aren't perfectly synchronized, as long as everybody agrees on the order of the events.
I do think this will be necessary. If User A and User B send User C a message at the same time, those two messages will both get queued from User A's and User B's Tunnelbroker instances. |