From: Yan, Zheng Date: Sun, 31 Mar 2013 06:19:17 +0000 (+0800) Subject: mds: don't roll back prepared table updates X-Git-Tag: v0.62~120^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=93ab1edd102a450a9f2bd39bb6245e8182f4b095;p=ceph.git mds: don't roll back prepared table updates 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 Reviewed-by: Greg Farnum --- diff --git a/src/mds/MDSTableClient.cc b/src/mds/MDSTableClient.cc index 2ce3286ee8ec..b47814970681 100644 --- a/src/mds/MDSTableClient.cc +++ b/src/mds/MDSTableClient.cc @@ -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); diff --git a/src/mds/MDSTableClient.h b/src/mds/MDSTableClient.h index f8a84ebf391a..16b14c4e164a 100644 --- a/src/mds/MDSTableClient.h +++ b/src/mds/MDSTableClient.h @@ -45,6 +45,7 @@ protected: }; map pending_prepare; + map prepared_update; list<_pending_prepare> waiting_for_reqid; // pending commits diff --git a/src/mds/MDSTableServer.cc b/src/mds/MDSTableServer.cc index 00bea5e14f19..b7752468c24e 100644 --- a/src/mds/MDSTableServer.cc +++ b/src/mds/MDSTableServer.cc @@ -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(); }