4 ms·
We use logical timestamps instead of datetime. So each "event" has three properties that allow us to resolve to a sensible order across clients: session (integ
by matlin 4y ago
We use logical timestamps instead of datetime.
So each "event" has three properties that allow us to resolve to a sensible order across clients: session (integer), device_id (uuid), order (integer). The `session` number is set by the highest `order` that your device has seen from the server and the `order` gets incremented on each new event.
So an example you might have a sequence of events like this.
[session] [order]
0 1
0 2
0 3
---sync ---
3 4
3 5
3 6
We can then sort all events by (session, device_id, order) and we'll get any events that happen on a device to be sorted in a row even if some other device created a bunch of concurrent events at the same time.
- Karrot_Kream 4y agoWhat about situations where two different clients both begin to publish new events from the same starting point? Those events can't be absolutely ordered right? If you're thinking of Lamport-style happens-before relations, then you can't enforce total ordering of those events. Do you just arbitrarily mark one of those client event streams as failed and force the client to absorb new state and try again?
- lifeisstillgood 4y agois there any reading around this - i just am not sure compsci papers cover this?
- Karrot_Kream 4y agoThey do, you're looking for reading around distributed systems topics. Lamport timestamps, a type of logical timestamp, are explained on Wikipedia [1]. You can use these to implement Vector Clocks [2]. I personally learned this by reading papers in undergrad and grad school as I researched in distributed systems, but I hear good things about Steen and Tanenbaum's Distributed Systems [3]. [1]: https://en.wikipedia.org/wiki/Lamport_timestamp https://en.wikipedia.org/wiki/Lamport_timestamp [2]: https://en.wikipedia.org/wiki/Vector_clock https://en.wikipedia.org/wiki/Vector_clock [3]: https://www.distributed-systems.net/index.php/books/ds3/ https://www.distributed-systems.net/index.php/books/ds3/