]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Paxos: update first_committed only from paxos
authorSage Weil <sage@inktank.com>
Tue, 25 Jun 2013 22:58:43 +0000 (15:58 -0700)
committerSage Weil <sage@inktank.com>
Wed, 26 Jun 2013 13:55:02 +0000 (06:55 -0700)
Do not touch the in-memory first_committed until the trim commits.  This
avoids any possible confusion due to races and keeps commit() as similar
to store_state() as possible.

Similarly, do not touch first_committed from store_state.  We should
*only* pull it out of the kv store.

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

index bbb488684c4b3bb6ff1258342f97de2f2b02f1b1..a952da3017102df01c5fc682c8ae4352d5bfc860 100644 (file)
@@ -291,8 +291,6 @@ void Paxos::store_state(MMonPaxos *m)
   map<version_t,bufferlist>::iterator end = start;
   while (end != m->values.end() && end->first <= m->last_committed) {
     last_committed = end->first;
-    if (!first_committed)
-      first_committed = last_committed;
     ++end;
   }
 
@@ -677,6 +675,9 @@ void Paxos::commit()
 
   get_store()->apply_transaction(t);
 
+  // refresh first_committed; this txn may have trimmed.
+  first_committed = get_store()->get(get_name(), "first_committed");
+
   _sanity_check_store();
 
   // tell everyone
@@ -974,7 +975,6 @@ void Paxos::trim_to(MonitorDBStore::Transaction *t, version_t first)
     return;
   trim_to(t, first_committed, first);
   t->put(get_name(), "first_committed", first);
-  first_committed = first;
 }
 
 void Paxos::trim_to(version_t first)