Atomic broadcast says: all correct processes deliver the same messages in the same order. ZAB strengthens this with primary-order, a property invented for the primary-backup model:
- Total order: if server A delivers transaction T1 before T2, then every server that delivers both delivers them in the same order.
- Primary order: if a primary p1 broadcasts T1 before handing leadership to p2, and p2 later broadcasts T2, then every server delivers T1 before T2.
- Primary integrity: p2 delivers all transactions broadcast by p1 before broadcasting its first own transaction.
These guarantees ride on two mechanisms. Every transaction carries a zxid — a 64-bit counter split into an epoch (upper 32 bits, incremented at each leader change) and a counter (lower 32 bits, reset to zero each epoch). A lexicographic comparison of zxids gives a total order across epochs. The two-phase broadcast (PROPOSAL → quorum ACK → COMMIT) ensures a message is only delivered after a quorum has acknowledged it, so no single failure can erase a committed write.
Recovery adds a third phase. The new leader collects the zxid histories of a quorum of followers, identifies the highest committed zxid among them, replicates any missing transactions to every follower, and only then broadcasts an epoch-bump NEW_EPOCH message. From that point the system re-enters normal operation. The whole recovery is bounded by the size of the backlog — O(n) messages where n is the number of un-delivered transactions — not by the total history.
Compare this with Raft: Raft is a general-purpose consensus algorithm that also handles leader election, log compaction and membership changes; ZAB is purpose-built for the primary-backup model and trades generality for a tighter primary-order contract. Both sit squarely in the family of problems related to distributed agreement — solvable in practice, but never in a system where nodes can fail arbitrarily without any timing assumptions at all.
Comments
Loading comments...