Unit content
Leader election and epochs
Some distributed protocols simplify coordination by designating one node as a leader for a period of time.
The hard part is not choosing a leader once, but preventing two old and new leaders from exercising conflicting authority after failures or delayed messages.
Protocols therefore attach a monotonically increasing epoch, term or generation number to leadership. Messages from an older epoch can be rejected after a newer epoch is established.
A leader may fail and another node may be elected, so leadership is a temporary protocol role rather than a permanent machine identity.
Leader election must preserve safety even when failure suspicion is wrong. A node that was merely disconnected can return later believing it is still leader; epoch checks let other participants recognize that its authority is stale.