Versions Compared

Key

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

...

  1. l The leader waits for a quorum of followers to connect all of whom has:
    • f.currentEpoch <= l.currentEpoch
    • if f.currentEpoch == l.currentEpoch, then f.lastZxid < l.lastZxid
  2. l Once the leader has quorum, it stops accepting connections, and sends NEWEPOCH(e) to all followers, where e is greater than all f.acceptedEpoch in the quorum.
  3. f Followers send ACK(e<<32) if e > f.acceptedEpoch. (If e < f.acceptedEpoch, the follower will abandon the leader. If e == f.acceptedEpoch, the follower will not send ACK(e<<32), but will still maintain the connection to the leader.)
  4. l The leader waits for all followers to ack NEWEPOCH(e)

Note, if a follower is connecting, but the leader is already established (in phase 3) the follower follows the phases, but the leader ignores any ACKs.

Phase 2: Sync with followers

  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 does it applies any changes and 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. l Leader starts accepting connections.

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.

...