I been reading about Election algorithms in Distributed Systems. I read about the Bully Algorithm and understood it. I came across A Ring Algorithm
, read about it an understood how it conducts the election but I could not understand how does it handle a situation when two processes 2
and 5
simultaneously discover that the coordinator 7
is not functioning.
Each of these builds an ELECTION message and start circulating it.Eventually, both messages will go all the way around,and both
2
and5
will convert them to COORDINATOR message, with exactly the same number and in the same order.
Who is going to be the coordinator (2
or 5
) and why according to this algorithm?
Say 2 and 5 discover that coordinator is not functioning, then both will initiate election algorithm.
Since the ring is unidirectional, the messages can only travel in one direction. The election message of 2 will reach 5 and election message of 5 will reach 2.
But interesting point is that whenever a node receives election message it appends its id to that message.Also when a node receives its own election message, it chooses the node with largest id to be new coordinator which will be 5 in both election message.
Hence 5 will become the coordinator and send the coordinator message.