]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Paxos: clean up removal of pre-conversion paxos states
authorSage Weil <sage@inktank.com>
Tue, 25 Jun 2013 23:54:58 +0000 (16:54 -0700)
committerSage Weil <sage@inktank.com>
Wed, 26 Jun 2013 13:55:02 +0000 (06:55 -0700)
Use a helper, independent of trim machinery, and call on leader, too.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/Paxos.cc
src/mon/Paxos.h

index a952da3017102df01c5fc682c8ae4352d5bfc860..ce9f2952e2a3f29d9eb59d7598ded0cc49ca4027 100644 (file)
@@ -326,17 +326,22 @@ void Paxos::store_state(MMonPaxos *m)
     _sanity_check_store();
   }
 
+  remove_legacy_versions();
+}
+
+void Paxos::remove_legacy_versions()
+{
   if (get_store()->exists(get_name(), "conversion_first")) {
-    MonitorDBStore::Transaction scrub_tx;
-    version_t cf = get_store()->get(get_name(), "conversion_first");
-    dout(10) << __func__ << " scrub paxos from " << cf
-            << " to " << first_committed << dendl;
-    if (cf < first_committed)
-      trim_to(&scrub_tx, cf, first_committed);
-    scrub_tx.erase(get_name(), "conversion_first");
-    get_store()->apply_transaction(scrub_tx);
+    MonitorDBStore::Transaction t;
+    version_t v = get_store()->get(get_name(), "conversion_first");
+    dout(10) << __func__ << " removing pre-conversion paxos states from " << v
+            << " until " << first_committed << dendl;
+    for (; v < first_committed; ++v) {
+      t.erase(get_name(), v);
+    }
+    t.erase(get_name(), "conversion_first");
+    get_store()->apply_transaction(t);
   }
-
 }
 
 void Paxos::_sanity_check_store()
@@ -698,6 +703,8 @@ void Paxos::commit()
 
   // get ready for a new round.
   new_value.clear();
+
+  remove_legacy_versions();
 }
 
 
index fcc0660402419f63db3893aec4197f29bb9499ef..810953c81012b2612e26258c1dd6b1f15c9ce6c8 100644 (file)
@@ -1087,6 +1087,12 @@ public:
    */
   void store_state(MMonPaxos *m);
   void _sanity_check_store();
+
+  /**
+   * remove legacy paxos versions from before conversion
+   */
+  void remove_legacy_versions();
+
   /**
    * Helper function to decode a bufferlist into a transaction and append it
    * to another transaction.