]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Paxos: update first_committed on first paxos proposal
authorJoao Eduardo Luis <joao.luis@inktank.com>
Mon, 1 Jul 2013 22:18:48 +0000 (23:18 +0100)
committerSage Weil <sage@inktank.com>
Mon, 1 Jul 2013 22:20:51 +0000 (15:20 -0700)
We were adding this update to a transaction that would only be applied
on the leader.  The peons would never see a first_committed > 0.

Fixes: #5484
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/mon/Paxos.cc

index 58c35d0305cabef318c6dbde6af3f7e99e276951..da00e400113c22fafdab51b0f396a9c215d19b0e 100644 (file)
@@ -489,15 +489,24 @@ void Paxos::begin(bufferlist& v)
   accepted.clear();
   accepted.insert(mon->rank);
   new_value = v;
+
+  if (last_committed == 0) {
+    MonitorDBStore::Transaction t;
+    // initial base case; set first_committed too
+    t.put(get_name(), "first_committed", 1);
+    decode_append_transaction(t, new_value);
+
+    bufferlist tx_bl;
+    t.encode(tx_bl);
+
+    new_value = tx_bl;
+  }
+
   // store the proposed value in the store. IF it is accepted, we will then
   // have to decode it into a transaction and apply it.
   MonitorDBStore::Transaction t;
   t.put(get_name(), last_committed+1, new_value);
 
-  // initial base case; set first_committed too
-  if (last_committed == 0)
-    t.put(get_name(), "first_committed", 1);
-
   dout(30) << __func__ << " transaction dump:\n";
   JSONFormatter f(true);
   t.dump(&f);