From: Sage Weil Date: Tue, 25 Jun 2013 04:07:09 +0000 (-0700) Subject: mon/Paxos: assert that the store gives us back what we just wrote X-Git-Tag: v0.67-rc1~175^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad9c294850a087190060fe098a2387ff0a344402;p=ceph.git mon/Paxos: assert that the store gives us back what we just wrote In bug #5424 I observed leveldb failing internally and then returning bad info. We then hit a random/confusing assert. Try to detect this earlier by verifying that a get of a just-written last_committed gives us back the right thing. Signed-off-by: Sage Weil Reviewed-by: Joao Eduardo Luis --- diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 2a324c97236d..4ccf52635ad1 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -327,6 +327,7 @@ void Paxos::store_state(MMonPaxos *m) get_store()->apply_transaction(t); + _sanity_check_store(); } if (get_store()->exists(get_name(), "conversion_first")) { @@ -342,6 +343,13 @@ void Paxos::store_state(MMonPaxos *m) } +void Paxos::_sanity_check_store() +{ + version_t lc = get_store()->get(get_name(), "last_committed"); + assert(lc == last_committed); +} + + // leader void Paxos::handle_last(MMonPaxos *last) { @@ -671,6 +679,8 @@ void Paxos::commit() get_store()->apply_transaction(t); + _sanity_check_store(); + // tell everyone for (set::const_iterator p = mon->get_quorum().begin(); p != mon->get_quorum().end(); diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index 4f1af82836e5..fcc066040241 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -1086,6 +1086,7 @@ public: * @param m A message */ void store_state(MMonPaxos *m); + void _sanity_check_store(); /** * Helper function to decode a bufferlist into a transaction and append it * to another transaction.