]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Paxos: break commit() into two pieces
authorSage Weil <sage@redhat.com>
Sun, 17 Aug 2014 05:22:01 +0000 (22:22 -0700)
committerSage Weil <sage@redhat.com>
Wed, 27 Aug 2014 21:36:07 +0000 (14:36 -0700)
One part happens before the txn starts, the other after.  Move all of the
internal state update to the bottom half.  Eventually this will matter.

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

index 4635c0ad0bfa3810a77868f6412bef299def7a5a..f3ddb5ed8467d1bc7411473f7b5e7a077e0062f8 100644 (file)
@@ -665,7 +665,7 @@ void Paxos::begin(bufferlist& v)
 
   if (mon->get_quorum().size() == 1) {
     // we're alone, take it easy
-    commit();
+    commit_start();
     if (do_refresh()) {
       assert(is_updating());  // we can't be updating-previous with quorum of 1
       commit_proposal();
@@ -793,7 +793,7 @@ void Paxos::handle_accept(MMonPaxos *accept)
   if (accepted == mon->get_quorum()) {
     // yay, commit!
     dout(10) << " got majority, committing, done with update" << dendl;
-    commit();
+    commit_start();
     if (!do_refresh())
       goto out;
     if (is_updating())
@@ -831,23 +831,16 @@ void Paxos::accept_timeout()
   mon->bootstrap();
 }
 
-void Paxos::commit()
+void Paxos::commit_start()
 {
-  dout(10) << "commit " << last_committed+1 << dendl;
-
-  // cancel lease - it was for the old value.
-  //  (this would only happen if message layer lost the 'begin', but
-  //   leader still got a majority and committed with out us.)
-  lease_expire = utime_t();  // cancel lease
+  dout(10) << __func__ << " " << (last_committed+1) << dendl;
 
   assert(g_conf->paxos_kill_at != 7);
 
   MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction);
 
   // commit locally
-  last_committed++;
-  last_commit_time = ceph_clock_now(g_ceph_context);
-  t->put(get_name(), "last_committed", last_committed);
+  t->put(get_name(), "last_committed", last_committed + 1);
 
   // decode the value and apply its transaction to the store.
   // this value can now be read from last_committed.
@@ -862,15 +855,29 @@ void Paxos::commit()
   logger->inc(l_paxos_commit);
   logger->inc(l_paxos_commit_keys, t->get_keys());
   logger->inc(l_paxos_commit_bytes, t->get_bytes());
-  utime_t start = ceph_clock_now(NULL);
+  commit_start_stamp = ceph_clock_now(NULL);
 
   get_store()->apply_transaction(t);
 
+  commit_finish();
+}
+
+void Paxos::commit_finish()
+{
+  dout(20) << __func__ << " " << (last_committed+1) << dendl;
   utime_t end = ceph_clock_now(NULL);
-  logger->tinc(l_paxos_commit_latency, end - start);
+  logger->tinc(l_paxos_commit_latency, end - commit_start_stamp);
 
   assert(g_conf->paxos_kill_at != 8);
 
+  // cancel lease - it was for the old value.
+  //  (this would only happen if message layer lost the 'begin', but
+  //   leader still got a majority and committed with out us.)
+  lease_expire = utime_t();  // cancel lease
+
+  last_committed++;
+  last_commit_time = ceph_clock_now(NULL);
+
   // refresh first_committed; this txn may have trimmed.
   first_committed = get_store()->get(get_name(), "first_committed");
 
index c38debd9fdcd8c95096c682d449a60f7473452a2..ed345a4144f811818bd32af49d01440f69935205 100644 (file)
@@ -320,7 +320,7 @@ private:
   /**
    * Last committed value's time.
    *
-   * When the commit happened.
+   * When the commit finished.
    */
   utime_t last_commit_time;
   /**
@@ -870,6 +870,9 @@ private:
    * @}
    */
 
+
+  utime_t commit_start_stamp;
+
   /**
    * Commit a value throughout the system.
    *
@@ -883,7 +886,8 @@ private:
    * @post Value locally stored
    * @post Quorum members instructed to commit the new value.
    */
-  void commit();
+  void commit_start();
+  void commit_finish();   ///< finish a commit after txn becomes durable
   /**
    * Commit the new value to stable storage as being the latest available
    * version.