]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Paxos: do paxos refresh in finish_proposal; and refactor
authorSage Weil <sage@inktank.com>
Sun, 2 Jun 2013 23:57:11 +0000 (16:57 -0700)
committerSage Weil <sage@inktank.com>
Mon, 24 Jun 2013 23:16:40 +0000 (16:16 -0700)
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 <sage@inktank.com>
(cherry picked from commit a42d7582f816b45f5d19c393fd45447555e78fdd)

src/mon/Paxos.cc
src/mon/Paxos.h

index 6adf191ee9191d99a5df8ac833c43b8266e728b3..0b90722de805dfe532d701d27d11a0bd27dde3db 100644 (file)
@@ -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<C_Proposal*>(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<C_Proposal*>(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;
index 04553776b931ea1eeffffaa68881729f3ae69994..ff299106ece37fd5ed9e5a9cf4b5ac2a58af1cd9 100644 (file)
@@ -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: