When checkpointing distributed pipelines without global pauses, use Chandy-Lamport FIFO Markers (or Flink-style aligned/unaligned barriers) to guarantee a Consistent Cut.
TL;DR30-second simplified summary▾
Snapshotting local state on the first Marker and logging other FIFO channels until their Markers arrive guarantees causal consistency—forming the basis for Flink's barrier snapshots.
a -> b): an effect cannot appear in a snapshot without its cause.P · Problem & Why Unsynchronized Backups Lose or Duplicate State.
Imagine two accounts: Node A starts with $100, Node B starts with $0. Node A sends a $50 transfer message to Node B.
If Node A checkpoints after deducting $50 (saving $50) while Node B checkpoints before the message arrives (saving $0), the global backup only totals $50—$50 disappeared into the network! Worse, if Node A checkpoints before sending ($100) and Node B checkpoints after receiving ($50), the backup totals $150—an impossible global state called an Inconsistent Cut.
Unsynchronized Wall-Clock Backup vs. Chandy-Lamport Consistent Cut
- $50 lost or duplicated in transit
- Inconsistent Cut (effect without cause)
- Requires stop-the-world pause to fix
- Captures node state + channel state
- Zero stop-the-world cluster pause
- Preserves exact $100 conservation
R · Representation: The Two Chandy-Lamport Marker Rules.
A Marker(snapshot_id) is a lightweight control message sent over the exact same FIFO channels as normal data messages—it can never overtake data sent before it.
Initiator Rule: Record local state S_i, mark all incoming channels as recording, and immediately send Marker on all outgoing channels. Receiver Rule: When Marker arrives on channel c_k: if this is the node's first Marker for snapshot_id, record local state S_j, mark c_k as empty (done), start recording all other incoming channels, and send Marker on all outgoing channels. If already snapshotted, simply stop recording c_k.
Node A Snapshots & Sends Marker -> Node B Snapshots -> Channel 2 Records In-Flight
I · Invariant: Why Every Cut Is Causally Consistent.
A global cut is consistent if for every event e2 included in the cut, every causal predecessor e1 -> e2 is also included.
Suppose Node B receives message m before Node B snapshots S_B. Could Node A have snapshotted S_A before sending m? Impossible! If A snapshotted before sending m, A sent Marker before m on the FIFO channel—so B would have received Marker (and snapshotted S_B) before m arrived!
Idle -> First Marker (Snapshot + Record Others) -> All Markers Received -> Done
M · Mechanics at Scale: From Chandy-Lamport to Flink Barriers.
In a streaming DAG (like Apache Flink), operators don't want to persist bulky in-flight channel buffers if they don't have to.
In Aligned Barrier Snapshotting, when an operator receives Barrier N on Channel 1 while Channel 2 is still behind, it temporarily blocks (buffers) Channel 1 in RAM and keeps draining Channel 2 until Barrier N arrives on Channel 2—then snapshots local state with zero channel messages!
Aligned Barriers (Zero Channel State) vs. Unaligned (Chandy-Lamport)
- Problem
- How to checkpoint a distributed stateful pipeline without stopping event ingestion.
- Naive Solution
- Pause all sources globally (
stop-the-world) until all queues drain, then backup. - Why It Fails
- Global pauses spike tail latency and waste cluster throughput on every checkpoint interval.
- Alternatives
- Stop-the-world vs. Aligned Barrier Checkpoints vs. Unaligned Chandy-Lamport Snapshots.
- Engineering Decision
- Use Aligned Barrier Checkpoints for low-backpressure DAGs (minimal snapshot size) and fall back to Unaligned Chandy-Lamport snapshots when alignment time exceeds a threshold.
- Trade-Offs
- Unaligned snapshots eliminate backpressure stalls at the cost of persisting in-flight network buffers in S3.
E · Edge Cases, Assumptions & When NOT to Use Chandy-Lamport.
Chandy-Lamport relies on two hard assumptions: (1) strongly connected directed graph (every node is reachable from the initiator), and (2) reliable FIFO channels.
When NOT to use Chandy-Lamport: over unordered UDP or multi-path networks where a Marker can overtake an earlier data packet! If a Marker arrives before a pre-snapshot message, that message is wrongly excluded from the cut—use Lai-Yang (piggybacked 1-bit color flags on every message) for non-FIFO networks instead.
TCP/FIFO (Chandy-Lamport) vs. Non-FIFO (Lai-Yang) vs. Backpressured DAG
An engineer implements Chandy-Lamport Marker snapshots over raw UDP sockets (without sequence numbers or reordering). Occasionally, snapshots lose in-flight messages. Why?
Practice: Make the trade-off yourself.
In the Chandy-Lamport algorithm, what does a receiver node do the FIRST time it receives a `Marker` on incoming channel `c_1`?