diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-03-02 16:39:13 -0500 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-03-21 15:35:28 -0400 |
commit | 5405dad12912c980b8ad30130fda0dd91b31b9d0 (patch) | |
tree | ab61614a3169e73db13fc941c44b6449d956f2ce /src/mongo/db/commands | |
parent | f3d6994262e2d9a26d68c043ace8849896590e17 (diff) | |
download | mongo-5405dad12912c980b8ad30130fda0dd91b31b9d0.tar.gz |
SERVER-22933 SERVER-22934 make applyOps update the last optime on no-ops, and add testing
(cherry picked from commit 24ea13cd77a295e4c33bce9af2deee8cb78e9cfc)
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/apply_ops.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/commands/apply_ops.cpp b/src/mongo/db/commands/apply_ops.cpp index 0a28bd7bbdd..12dc70ceb86 100644 --- a/src/mongo/db/commands/apply_ops.cpp +++ b/src/mongo/db/commands/apply_ops.cpp @@ -57,6 +57,7 @@ #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/write_concern.h" #include "mongo/util/log.h" +#include "mongo/util/scopeguard.h" namespace mongo { @@ -118,8 +119,23 @@ public: txn->setWriteConcern(wcResult.getValue()); setupSynchronousCommit(txn); + + auto client = txn->getClient(); + auto lastOpAtOperationStart = repl::ReplClientInfo::forClient(client).getLastOp(); + ScopeGuard lastOpSetterGuard = + MakeObjGuard(repl::ReplClientInfo::forClient(client), + &repl::ReplClientInfo::setLastOpToSystemLastOpTime, + txn); + auto applyOpsStatus = appendCommandStatus(result, applyOps(txn, dbname, cmdObj, &result)); + if (repl::ReplClientInfo::forClient(client).getLastOp() != lastOpAtOperationStart) { + // If this operation has already generated a new lastOp, don't bother setting it + // here. No-op applyOps will not generate a new lastOp, so we still need the guard to + // fire in that case. + lastOpSetterGuard.Dismiss(); + } + WriteConcernResult res; auto waitForWCStatus = waitForWriteConcern(txn, |