From ac63b2e0952b782460af75163c3bc429cfb8abdd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 25 Jun 2013 16:54:58 -0700 Subject: [PATCH] mon/Paxos: clean up removal of pre-conversion paxos states Use a helper, independent of trim machinery, and call on leader, too. Signed-off-by: Sage Weil --- src/mon/Paxos.cc | 25 ++++++++++++++++--------- src/mon/Paxos.h | 6 ++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index a952da3017102..ce9f2952e2a3f 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -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(); } diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index fcc0660402419..810953c81012b 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -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. -- 2.39.5