]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Paxos needs to store the latest version permanently on-disk.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 23 Mar 2012 17:31:29 +0000 (10:31 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 27 Mar 2012 20:57:49 +0000 (13:57 -0700)
Previously it was only storing this m->latest_value in the stash,
which of course got overwritten. And then when somebody tried to read
it back, it failed!
Instead, require that the message include the regular version (not
just the stashed version), which the previous commit provides. And then
write the regular version to disk alongside the stash.

This set of procedures still suffers from some of the same disk consistency
issues as we recently fixed in slurping, but it's better than it was, and
fixing those would require a good deal more work.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/mon/Paxos.cc

index a969ccad593c164b8ae62e3e85b5e8b2e860932c..fda4662ab5eded3ebf65727a8f00c9d306be68b3 100644 (file)
@@ -191,10 +191,14 @@ void Paxos::share_state(MMonPaxos *m, version_t peer_first_committed, version_t
 
 void Paxos::store_state(MMonPaxos *m)
 {
+  map<version_t,bufferlist>::iterator start = m->values.begin();
+
   // stash?
   if (m->latest_version && m->latest_version > last_committed) {
     dout(10) << "store_state got stash version " << m->latest_version << ", zapping old states" << dendl;
 
+    assert(start != m->values.end() && start->first == m->latest_version);
+
     // wipe out everything we had previously
     trim_to(last_committed + 1);
 
@@ -202,14 +206,13 @@ void Paxos::store_state(MMonPaxos *m)
 
     first_committed = m->latest_version;
     last_committed = m->latest_version;
+    mon->store->put_bl_sn(start->second, machine_name, m->latest_version);
     mon->store->put_int(first_committed, machine_name, "first_committed");
     mon->store->put_int(last_committed, machine_name, "last_committed");
   }
 
   // build map of values to store
   // we want to write the range [last_committed, m->last_committed] only.
-  map<version_t,bufferlist>::iterator start = m->values.begin();
-
   if (start != m->values.end() &&
       start->first > last_committed + 1) {
     // ignore everything if values start in the future.