A logical clock is a protocol-maintained ordering mechanism for representing event or system-state progression without relying on synchronized physical time. It supports conflict resolution and replica coordination when wall-clock drift makes event ordering unreliable. section 11.3.2 section 4.7
A Lamport timestamp maintains causal order through a local counter:
- Initialize each process’s counter to zero. section 11.3.2
- Include the current counter when sending a message. section 11.3.2
- On receipt, set the local counter to the greater of the local and received values, then increment it. section 11.3.2
- Compare counter values to order events connected by a causal relationship, commonly called happens-before. section 11.3.2
Logical clocks do not measure elapsed physical time and do not identify which of two concurrent events happened first. Vector clocks can represent concurrency, but require growing metadata for participant state. A node ID can provide a deterministic tie-breaker when conflicting updates share a logical time. section 11.3.2 section 11.3.2
Optimistic updates and replicated views
For last-writer-wins reconciliation, clients can attach a Lamport timestamp or vector clock and node ID to updates instead of trusting synchronized wall clocks. In Viewstamped Replication, each primary-backed period receives a view number; incrementing it during a primary change gives replicas a logical marker for the current system state. section 11.3.2 section 4.7
Figure 11.5 Lamport timestamps record the causal relationship between events. Each process maintains a counter, which increments every time the process sends out a message. The process includes the counter as part of the sent-out message, and when another process receives the message, the process updates its timestamp either to its current value or to the value of the received timestamp, whichever is greater. In this example, you have three processes sending and receiving messages.
Trace counter updates across three communicating processes to visualize how Lamport timestamps preserve causal ordering. section 11.3.2

