]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Paxos: only finish a queued proposal if there's actually *any*
authorJoao Eduardo Luis <joao.luis@inktank.com>
Tue, 12 Mar 2013 12:37:01 +0000 (12:37 +0000)
committerSage Weil <sage@inktank.com>
Wed, 13 Mar 2013 22:03:00 +0000 (15:03 -0700)
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 <joao.luis@inktank.com>
src/mon/Paxos.cc
src/mon/Paxos.h

index 53476f8a67eda99a3d1870e0fe12ad80c8de9b4f..1a21ff37b173b89b64495842b79bf1f3f9198bf9 100644 (file)
@@ -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<C_Proposal*>(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;
index df854cb84f8acdc924727533325cf3fd994f90db..8fcf66b25db95d03c50bbf5e6bc72800cf0b4fbf 100644 (file)
@@ -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: