From fe365339b9ff2d45be6c41aa66646ae3d80e5715 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 25 Jun 2013 15:43:33 -0700 Subject: [PATCH] mon/Paxos: never write first_committed except during trim The trimming is handled by proposing transactions. Do not confuse matters by writing (incorrect) first_committed values at any other point. Signed-off-by: Sage Weil --- src/mon/Paxos.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 4ccf52635ad1a..77baef405035b 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -302,11 +302,6 @@ void Paxos::store_state(MMonPaxos *m) dout(10) << "store_state [" << start->first << ".." << last_committed << "]" << dendl; t.put(get_name(), "last_committed", last_committed); - // we write our first_committed version before we append the message's - // transaction because this transaction may be a trim; if so, it will - // update the first_committed value, and we must let it clobber our own - // in order to obtain an updated state. - t.put(get_name(), "first_committed", first_committed); // we should apply the state here -- decode every single bufferlist in the // map and append the transactions to 't'. map::iterator it; @@ -327,6 +322,9 @@ void Paxos::store_state(MMonPaxos *m) 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(); } @@ -662,10 +660,6 @@ void Paxos::commit() last_committed++; last_commit_time = ceph_clock_now(g_ceph_context); t.put(get_name(), "last_committed", last_committed); - if (!first_committed) { - first_committed = last_committed; - t.put(get_name(), "first_committed", last_committed); - } // decode the value and apply its transaction to the store. // this value can now be read from last_committed. -- 2.39.5