Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. l The leader does the following with each follower connected to it:
    1. adds the follower to the list of connections to send new proposals, so while the server is performing the next steps, it is queuing up any new proposals sent to the follower.
    2. does one of the following:
      • SNAP if the follower is so far behind that it is better to do a state transfer than send missing transactions.
      • TRUNC(zxid) if the follower has transactions that the leader has chosen to skip. The leader sets zxid to the last zxid in its history for the epoch of the follower.
      • DIFF if the leader is sending transactions that the follower is missing. The leader sends missing messages to the follower.
    3. sends a NEWLEADER(e);
    4. The leader releases any queued messages to the follower.
  2. f The follower syncs with the leader, but doesn't modify its state until it receives the NEWLEADER(e) packet. Once it receives NEWLEADER(e) it atomically applies the new state and sets f.currentEpoch = e. It then sends ACK(e << 32).
  3. l Once the leader has received an acknowledgements from a quorum of followers, it takes leadership of epoch e and queues UPTODATE to all followers.
  4. f When a follower receives the UPDATE message, it starts accepting client connections and serving new state.
  5. l Leader starts accepting connections from followers again. The variable nextZxid is set to (e << 32) + 1.

Phase 3: Broadcast

The leader and followers can have multiple proposals in process and at various stages in the pipeline. The leader will remain active as long as there is a quorum of followers acknowledging its proposals or pings within a timeout interval. The follower will continue to support a leader as long as it receives proposals or pings within a timeout interval. Any failures or timeouts will result in the server going back to leader election.

  1. l the leader queues a packet PROPOSE(zxid, data), where zxid = nextZxid to all connected followers, and increments nextZxid.
  2. f a follower will log and sync proposals to disk and send ACK(zxid).
  3. l when the leader receives acknowledgements from a quorum of followers it queues COMMIT(zxid) to all followers.