Ordering a Sequence of Events
A sequence can store arrival order, time order, or another ordering rule. Choose consistently before computing neighbors or the latest event.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Distinguish two records
A message stamped 9:00 can arrive after one stamped 9:02. Arrival order and timestamp order disagree for those records. Key-based sorting can reorder by time if that is the chosen observation.
Resolve ties reproducibly
Two records with the same time can retain arrival order under a stable sort, or a second key can resolve a tie. A scan from the back finds the latest matching event only after that rule determines what appears last.[1]
Keep chronological facts separate from arrival order
A device can send event A with timestamp twelve, then send B with timestamp eleven after a retry. A display ordered by arrival shows A then B. A display ordered by recorded event time can show B then A. Each view answers a different question. When a late event should revise a statistic, retain enough identity to avoid counting a retried delivery twice. See deduplicating in input order.
Use a deterministic tie rule with realistic failures
Two distinct events can have the same timestamp, especially when clocks record only whole seconds. A stable sort preserves their input order but two consumers may receive those inputs in a different order. When consumers must agree, include a shared, unique tie-breaker. If event times originate on separate machines, explicitly consider clock error before using them to infer cause. Test the same two events in both arrival orders. See stable ordering.