]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Paxos: assert that the store gives us back what we just wrote
authorSage Weil <sage@inktank.com>
Tue, 25 Jun 2013 04:07:09 +0000 (21:07 -0700)
committerSage Weil <sage@inktank.com>
Wed, 26 Jun 2013 04:25:04 +0000 (21:25 -0700)
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 <sage@inktank.com>
Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/Paxos.cc
src/mon/Paxos.h

index 2a324c97236d05af0fd2873fa7dd1a75b4d4032c..4ccf52635ad1a6cefdf52547329a7ee2a341b442 100644 (file)
@@ -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<int>::const_iterator p = mon->get_quorum().begin();
        p != mon->get_quorum().end();
index 4f1af82836e5f82a2f98ddc5a9e25a010f18c48b..fcc0660402419f63db3893aec4197f29bb9499ef 100644 (file)
@@ -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.