Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Simple Leader Election

WATANBE Noritakaa)
To elect a leader in a distributed system, Paxos lease algorithm is
typically used. This paper describes another simple leader election
algorithm based on the primitive majority principle, and it makes
each replica can individually recognize the leader.

1.

negotiations with others.


It is based on the primitive majority principle.
Choice values in any majority group are the
same because all majority groups have at least
one common replica which has the only one
vote.

Introduction

In a distributed system, a leader or master is


generally needed to make the system progress.
And to elect a leader in the distributed system,
we have to take care of a single point of failure.
That means, when the only one agent that is
dedicated to elect a leader fails, we are not able
to get the leader.
To avoid this problem, Paxos lease algorithm
[1] or a network lock system are generally used.
But the former has weak points. When more
than two want to get a leader at the same time,
they cannot elect a leader. This is collision,
which occurs very rarely and more likely. And
also other replicas cannot recognize a leader
without the notification of leader election from
the decider even when decided. The latter
seems safe, but a network lock system does also
use Paxos. So, this seems very funny.
We need another algorithm which is different
from Paxos and makes each replica recognize a
leader individually.

2.

3.

Candidate of leader

In order to vote, each replica must have some


data to select. We use birth time as data, which
are sent from others. And we pick up the oldest
one by selection rule, and its replica ID as vote
value. Steps are as follows.
The first step: each replica sends its birth time
to others.
The second step: every when each replica
receives those data, it selects the oldest one in
the received and connected set including itself,
as a candidate of leader and sends this ID to
others as vote.
The third step: each replica individually
recognizes the leader when the majority votes
the same ID. In the case of no majority, it
recognizes no leader.
As to transactions, this protocol is done by
2-ways, sending birth time and sending
candidate. Paxos lease is 3-ways, propose,
accept and notify the leader to others.

Individual recognition of leader

Let each replica has the only one vote and


communicates each other by sending their
votes.
Each replica checks votes received from others,
and when some value gets the majority of votes,
it can by itself recognize this value as the
elected value in the system without more

4. Heartbeat
In software program, it is impossible to
communicate continuously each other like
hardware wired. So, heartbeat is generally
used in software program, therefore some

Tritech Inc.
a) E-mail: nw@tritech.co.jp
March, 2012

time lag is inevitable.


In heartbeat, each replica sends its birth time
packet to others. But it is unsure that this
packet reaches others, as well as candidate
packet.
So, because of time lag or packet lost etc., some
turbulent state will occur about leader election
until communication state reaches stable. For
example, at the same time, replica A may
recognize replica a as leader by As majority,
replica B may also recognize replica b as leader
by Bs majority, even though every replica votes
the only one candidate. This is called jeopardous
state.
And clients have to wait until the stable state
reaches. They also have to know the state of
election; no leader, the leader elected and
jeopardous. This is the issue which is related to
communication between client and replicas, and
out of the scope of this paper.
The oldest one in all replicas is not always
elected because of network partitioning. But,
even if the oldest one is isolated from others, the
system can autonomously elect the leader.
And to avoid election turbulence, it is good idea
for the leader to rebirth when it loses its
leadership.

5.

with some RAS detection of the failure of leader,


we can immediately get a new leader.

[1] Marton Trencseni, Attila Gazso, Holger


Reinhardt. PaxosLease: Diskless Paxos for Leases.
https://docs.google.com/gview?url=http://scalien.com/p
df/PaxosLease.pdf

Immediate change of leader

As long as using heartbeat, we have to allow


some time lag. Making time interval shorter is
not true solution.
But, just after the detection of the failure of
leader, we can force the system to immediately
elect the leader. On the failure of leader, the
detector asks every replica to send its birth time
packet to others like heartbeat. And following
the above process, every replica can
immediately recognize the leader.

6.

Conclusions

This simple leader election algorithm is


different from Paxos algorithm.
In this algorithm, there are no collision and no
funny. Each replica can individually decide the
leader without more negotiations to others, and
2

You might also like