diff options
author | Judah Schvimer <judah@mongodb.com> | 2016-04-12 19:11:23 -0400 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2016-04-12 19:11:23 -0400 |
commit | 7ed530a55304bd9cc2b80c054f379b10d9cea8e2 (patch) | |
tree | ff1dac44961da031f3369f0288fb38a347d0d690 /src/mongo/db/commands/find_and_modify.cpp | |
parent | b0c0acc6767a74ed2e5aa50361ad4474291951f9 (diff) | |
download | mongo-7ed530a55304bd9cc2b80c054f379b10d9cea8e2.tar.gz |
SERVER-20224 commands that write support writeConcern
Diffstat (limited to 'src/mongo/db/commands/find_and_modify.cpp')
-rw-r--r-- | src/mongo/db/commands/find_and_modify.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index 32b48d4eb3e..c806e67bdb7 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -63,6 +63,7 @@ #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/write_concern.h" +#include "mongo/s/d_state.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" @@ -214,6 +215,9 @@ public: bool slaveOk() const override { return false; } + virtual bool supportsWriteConcern(const BSONObj& cmd) const override { + return true; + } void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) override { @@ -332,13 +336,6 @@ public: const FindAndModifyRequest& args = parseStatus.getValue(); const NamespaceString& nsString = args.getNamespaceString(); - StatusWith<WriteConcernOptions> wcResult = extractWriteConcern(txn, cmdObj, dbName); - if (!wcResult.isOK()) { - return appendCommandStatus(result, wcResult.getStatus()); - } - txn->setWriteConcern(wcResult.getValue()); - setupSynchronousCommit(txn); - boost::optional<DisableDocumentValidation> maybeDisableValidation; if (shouldBypassDocumentValidationForCommand(cmdObj)) maybeDisableValidation.emplace(txn); @@ -350,6 +347,11 @@ public: &repl::ReplClientInfo::setLastOpToSystemLastOpTime, txn); + // If this is the local database, don't set last op. + if (dbName == "local") { + lastOpSetterGuard.Dismiss(); + } + // Although usually the PlanExecutor handles WCE internally, it will throw WCEs when it is // executing a findAndModify. This is done to ensure that we can always match, modify, and // return the document under concurrency, if a matching document exists. @@ -507,14 +509,6 @@ public: lastOpSetterGuard.Dismiss(); } - WriteConcernResult res; - auto waitForWCStatus = - waitForWriteConcern(txn, - repl::ReplClientInfo::forClient(txn->getClient()).getLastOp(), - txn->getWriteConcern(), - &res); - appendCommandWCStatus(result, waitForWCStatus); - return true; } |