On 2020-12-03 06:41, Liu, Changcheng wrote:
Hi all,
I'm studying Paxos in Ceph because I need to add one new
PaxosService.
In Ceph, the Paxos is based on a single-proposer & multi-acceptors.
So, the quorum need choose the single-proposer(leader) first.
It seems that there're two ways to choose one monitor as leader:
I'm curious that why their pre-conditions are different.
------------
This doesn't block me to continue my development work. I just want to
know why.
Does anyone know that reason?
I. Normal way:
Elector::handle_ack
|--> logic.receive_ack(peer_rank, m->epoch);
|--> declare_victory();
// Note: pre-condition is below
-------------
electing_me && (acked_me.size() ==
elector->paxos_size())
II. Another way if timeout event happen:
Elector::_start() or Elector::_defer_to
|--> reset_timer();
|--> expire_event = mon->timer.add_event_after(
g_conf()->mon_election_timeout + plus,
new C_MonContext{
mon, [this](int) {
logic.end_election_period();
}
});
When timeout happens:
ElectionLogic::end_election_period()
|--> declare_victory();
// Note: pre-condition is below
-------------
electing_me && acked_me.size() > (elector->paxos_size() /
2)
In a nutshell, the first is a declaration of victory when all other
monitors have acknowledged the winner; the latter is in the event that
some monitors may not have replied at all. The latter is useful when you
have dead monitors, or monitors that may have not been able to reply to
the election thus keeping any monitor from winning through the normal
path.
Hope this helps.
-Joao
_______________________________________________
Dev mailing list -- dev@xxxxxxx
To unsubscribe send an email to dev-leave@xxxxxxx