From: Sage Weil Date: Sun, 2 Jun 2013 23:57:11 +0000 (-0700) Subject: mon/Paxos: do paxos refresh in finish_proposal; and refactor X-Git-Tag: v0.66~47^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a42d7582f816b45f5d19c393fd45447555e78fdd;p=ceph.git mon/Paxos: do paxos refresh in finish_proposal; and refactor Do the paxos refresh inside finish_proposal, ordered *after* the leader assertion so that MonmapMonitor::update_from_paxos() calling bootstrap() does not kill us. Also, remove unnecessary finish_queued_proposal() and move the logic inline where the bad leader assertion is obvious. Signed-off-by: Sage Weil --- diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 54579393c4da..9c6d11345e8f 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -509,7 +509,6 @@ void Paxos::begin(bufferlist& v) // we're alone, take it easy commit(); state = STATE_ACTIVE; - mon->refresh_from_paxos(); finish_proposal(); finish_contexts(g_ceph_context, waiting_for_active); finish_contexts(g_ceph_context, waiting_for_commit); @@ -628,8 +627,6 @@ void Paxos::handle_accept(MMonPaxos *accept) state = STATE_ACTIVE; extend_lease(); - mon->refresh_from_paxos(); - finish_proposal(); // wake people up @@ -784,40 +781,30 @@ void Paxos::warn_on_future_time(utime_t t, entity_name_t from) } -void Paxos::finish_queued_proposal() +void Paxos::finish_proposal() { 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;; - assert(proposal != NULL); + // make sure we have the latest state loaded up + mon->refresh_from_paxos(); - if (!proposal->proposed) { - dout(10) << __func__ << " we must have received a stay message and we're " - << "trying to finish before time. " - << "Instead, propose it (if we are active)!" << dendl; - } else { - dout(10) << __func__ << " proposal took " - << (ceph_clock_now(NULL) - proposal->proposal_time) - << " to finish" << dendl; + // finish off the last proposal + if (!proposals.empty()) { + assert(mon->is_leader()); - proposals.pop_front(); - proposal->complete(0); + C_Proposal *proposal = static_cast(proposals.front()); + if (!proposal->proposed) { + dout(10) << __func__ << " proposal " << proposal << ": we must have received a stay message and we're " + << "trying to finish before time. " + << "Instead, propose it (if we are active)!" << dendl; + } else { + dout(10) << __func__ << " proposal " << proposal << " took " + << (ceph_clock_now(NULL) - proposal->proposal_time) + << " to finish" << dendl; + proposals.pop_front(); + proposal->complete(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 04553776b931..ff299106ece3 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -994,7 +994,6 @@ private: * Begin proposing the Proposal at the front of the proposals queue. */ void propose_queued(); - void finish_queued_proposal(); void finish_proposal(); public: