liveBook · Manning

Happens-before relation

As explained in Think Distributed Systems

The happened-before relationship is a causal ordering relation in which one distributed-system event precedes another through local execution and message communication.

The happens-before relation orders distributed-system events by possible causality. Event a precedes b when a occurs earlier on one component, sends the message that b receives, or reaches b through transitivity. section 2.2.1

Use the relation to distinguish three cases:

A message creates a causal chain

If component A sends a message and component B receives it, the send happened before the receive. Any event after that receive also follows the send, even when the events occur on different components. section 2.2.1

Table 2.2 Happened-before relationships

Situation

Notation

a happened before b.

a → b

b happened before a.

b → a

a and b are concurrent.

a || b = b || a

Compare the notation for precedence and concurrency, alongside diagrams of local, message-based, and transitive ordering. section 2.2.1

Logical time makes happened-before order usable: Lamport clocks timestamp events, while Kafka offsets and etcd sequence numbers provide related ordering within their respective scopes. section 2.2.4

How Think Distributed Systems covers it

How deep it goes
Defines local, message-based, transitive, and concurrent ordering, then connects it to logical clocks.
Examples
Uses local events, message send and receive pairs, Lamport clocks, Kafka partition offsets, and etcd sequence numbers.
What you can do after
Evaluate whether distributed events may be causally ordered or concurrent, and apply logical timestamps to represent that order.
How it connects
Connects distributed systems with causality, concurrency, parallelism, logical time, and logical clocks.

Also explained in

Compare how 5 books explain happens-before relation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Think Distributed Systems. The section links point to the parts of the book it draws on.