Introduction

Point of leader election is that (1) only one leader election; and (2) everyone knows who the leader is

Setup


⭕ Ring-Based

Worst-case: Initiator is one after the highest id → 3(N-1) messages and completion time

Best-case: Initiator is the highest id → 2N messages and completion time

image.png

⚠️ Problem: if elected leader dies but their elected message lives on, we are in trouble!!

✅ no real solution other than using a failure detector and hoping it catches the failure and initiates a new election


👺 Bully Algorithm

Similar to ring but smarter with re-election upon old leader dying

# once leader dies 

p = process that detected the failure 

if p.id == max(ids_in_my_membership_list)
	**elect self as leader and tell everyone** 
	everyone elects p 

else
	initiate new election -> send ONLY to processes with ids > p.id # avoid wasted effort to send to all peers 
	
	if no messages within timeout: 
		**elect self as leader and tell everyone** 
		
	else if answer from higher id rcved:
		wait for election message from that higher id processs

Is this safe?

image.png

Worst-case: lowest id detects failure → N^2 messages