Broadcasting ordered updates
ZAB, the ZooKeeper Atomic Broadcast protocol, keeps replicas of a small coordination data tree in sync. It is a primary backup scheme: a single elected leader sequences all state changes and broadcasts them so every follower applies the same transactions in the same order.
Epochs and zxids
Each leadership reign is an epoch. Every transaction gets a zxid, a 64 bit identifier whose high bits are the epoch and low bits a counter. This makes ordering total and lets nodes compare how up to date their histories are.
- Discovery: a new leader learns the most recent history among a quorum so no committed transaction is lost.
- Synchronization: the leader pushes its history to followers, bringing them to a common state.
- Broadcast: the leader proposes new transactions, and a quorum of acks commits each one in zxid order.
Why ordering holds
A leader only commits transactions from its own epoch after its initial history is established, and higher epochs always supersede lower ones. Recovery guarantees that anything committed in an old epoch survives into the new one.
Key idea
ZAB orders all updates through a single leader using epochs and zxids, with discovery and synchronization phases that preserve every committed transaction across leader changes.