6. Chapter 6: Coordination and Agreement
6.4. Elections Algorithm
Elections Algorithm
- Need to find one process that is the coordinator
- Assume
- Each process has a unique identifier (for example, network address)
- One process per machine
- Every process knows the process number of every other process
- Processes don’t know which processes are down and which ones are still running
- End result of the algorithm: all processes agree on who is the new coordinator/leader
- Bully algorithm & Ring Algorithm

Ring-based
Elections
Does NOT use a token
Assume
- processes are ordered
- each process knows its successor and the successor’s successor, and so on (needed in case of failures)
Process P detects that the coordinator is dead
- sends an ELECTION message to its successor
- includes its process number in the message
- each process that receives it, adds its own process number and then forwards it to its successor
- eventually it gets back that message, now what does it do?




Figure
6.7: A ring-based election in progress

A process notices that coordinator is not responding
- it starts an election (any process can start one)
Election algorithm
- P sends an ELECTION message to processes with higher numbers
- If no one responds, P wins the election
- If some process with higher process number responds
- P’s job is done, that process takes over
- the receiver sends an OK message to P
- receiver starts an election process
Eventually all processes give up, except one
This process sends out a message saying that it is the new “COORDINATOR”
A process that was down, when it comes back up starts a new election of its own
The bully algorithm