]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: don't roll back prepared table updates
authorYan, Zheng <zheng.z.yan@intel.com>
Sun, 31 Mar 2013 06:19:17 +0000 (14:19 +0800)
committerGreg Farnum <greg@inktank.com>
Mon, 1 Apr 2013 16:26:24 +0000 (09:26 -0700)
When table server is recovering, it re-sends 'agree' messages for
prepared table updates. It is possible table client receives an
'agree' messages before it commits the corresponding update. Don't
send 'rollback' message back to the server in this case.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/mds/MDSTableClient.cc
src/mds/MDSTableClient.h
src/mds/MDSTableServer.cc

index 2ce3286ee8ec95e63d55c7c57b44406bbc20aa4f..b47814970681b887ed365177d9cbd554fd57cae5 100644 (file)
@@ -59,11 +59,17 @@ void MDSTableClient::handle_request(class MMDSTableRequest *m)
       if (pending_prepare[reqid].pbl)
        *pending_prepare[reqid].pbl = m->bl;
       pending_prepare.erase(reqid);
+      prepared_update[tid] = reqid;
       if (onfinish) {
         onfinish->finish(0);
         delete onfinish;
       }
-    } 
+    }
+    else if (prepared_update.count(tid)) {
+      dout(10) << "got duplicated agree on " << reqid << " atid " << tid << dendl;
+      assert(prepared_update[tid] == reqid);
+      assert(!server_ready);
+    }
     else if (pending_commit.count(tid)) {
       dout(10) << "stray agree on " << reqid << " tid " << tid
               << ", already committing, will resend COMMIT" << dendl;
@@ -162,6 +168,9 @@ void MDSTableClient::commit(version_t tid, LogSegment *ls)
 {
   dout(10) << "commit " << tid << dendl;
 
+  assert(prepared_update.count(tid));
+  prepared_update.erase(tid);
+
   assert(pending_commit.count(tid) == 0);
   pending_commit[tid] = ls;
   ls->pending_commit_tids[table].insert(tid);
index f8a84ebf391a2428f4037af1f941f27574b58166..16b14c4e164a5e91f1cbc35e0c22dd9e9a2345fa 100644 (file)
@@ -45,6 +45,7 @@ protected:
   };
 
   map<uint64_t, _pending_prepare> pending_prepare;
+  map<version_t, uint64_t> prepared_update;
   list<_pending_prepare> waiting_for_reqid;
 
   // pending commits
index 00bea5e14f19ea08078cf303501ffe627fe84ba6..b7752468c24e75e99e49da3572acb01c5dd6a633 100644 (file)
@@ -120,10 +120,13 @@ void MDSTableServer::_commit_logged(MMDSTableRequest *req)
 void MDSTableServer::handle_rollback(MMDSTableRequest *req)
 {
   dout(7) << "handle_rollback " << *req << dendl;
-  _rollback(req->get_tid());
-  _note_rollback(req->get_tid());
+
+  version_t tid = req->get_tid();
+  assert(pending_for_mds.count(tid));
+  _rollback(tid);
+  _note_rollback(tid);
   mds->mdlog->start_submit_entry(new ETableServer(table, TABLESERVER_OP_ROLLBACK, 0, -1, 
-                                                 req->get_tid(), version));
+                                                 tid, version));
   req->put();
 }