From: Joao Eduardo Luis Date: Tue, 12 Mar 2013 12:37:01 +0000 (+0000) Subject: mon: Paxos: only finish a queued proposal if there's actually *any* X-Git-Tag: v0.59~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b99367bfb2c1a98df901c073b9b4e9b7aceb21bd;p=ceph.git mon: Paxos: only finish a queued proposal if there's actually *any* When proposing an older value learned during recovery, we don't create a queued proposal -- we go straight through Paxos. Therefore, when finishing a proposal, we must be sure that we have a proposal in the queue before dereferencing it, otherwise we will segfault. Fixes: #4250 Signed-off-by: Joao Eduardo Luis --- diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 53476f8a67ed..1a21ff37b173 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -783,20 +783,17 @@ void Paxos::warn_on_future_time(utime_t t, entity_name_t from) } -void Paxos::finish_proposal() +void Paxos::finish_queued_proposal() { - /* There is a lot of debug still going around. We will get rid of it later - * on, as soon as everything "just works (tm)" - */ assert(mon->is_leader()); + assert(!proposals.empty()); dout(10) << __func__ << " finishing proposal" << dendl; C_Proposal *proposal = static_cast(proposals.front()); dout(10) << __func__ << " finish it (proposal = " << proposal << ")" << dendl;; - if (!proposal) // this is okay. It happens when we propose an old value. - return; + assert(proposal != NULL); if (!proposal->proposed) { dout(10) << __func__ << " we must have received a stay message and we're " @@ -810,6 +807,16 @@ void Paxos::finish_proposal() proposals.pop_front(); proposal->finish(0); } +} + +void Paxos::finish_proposal() +{ + /* There is a lot of debug still going around. We will get rid of it later + * on, as soon as everything "just works (tm)" + */ + assert(mon->is_leader()); + if (!proposals.empty()) + finish_queued_proposal(); dout(10) << __func__ << " state " << state << " proposals left " << proposals.size() << dendl; diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index df854cb84f8a..8fcf66b25db9 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -987,6 +987,7 @@ private: * Begin proposing the Proposal at the front of the proposals queue. */ void propose_queued(); + void finish_queued_proposal(); void finish_proposal(); public: