diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2020-03-10 15:31:12 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-30 21:34:41 +0000 |
commit | 030a1b3c2eb5d4973c72ed661b4f97acd3e3d332 (patch) | |
tree | 71f8c8dac916fcf33a69b89d54ea876094e40535 /src | |
parent | 850aee41530b07e6918530cc377c165da652b94e (diff) | |
download | mongo-030a1b3c2eb5d4973c72ed661b4f97acd3e3d332.tar.gz |
SERVER-44333 Extend write concern validation for mongos
Mongos should not accept an empty (default) write concern for commands that do not support write concerns.
(cherry picked from commit e0077e34ae71580f99205db961980f0403665652)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/s/commands/strategy.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp index dfa2041878e..befba35ecd2 100644 --- a/src/mongo/s/commands/strategy.cpp +++ b/src/mongo/s/commands/strategy.cpp @@ -63,6 +63,7 @@ #include "mongo/db/stats/counters.h" #include "mongo/db/transaction_validation.h" #include "mongo/db/views/resolved_view.h" +#include "mongo/db/write_concern_options.h" #include "mongo/logv2/log.h" #include "mongo/rpc/factory.h" #include "mongo/rpc/get_status_from_command_result.h" @@ -444,10 +445,9 @@ void runCommand(OperationContext* opCtx, } bool supportsWriteConcern = invocation->supportsWriteConcern(); - if (!supportsWriteConcern && !wc.usedDefault) { + if (!supportsWriteConcern && + request.body.hasField(WriteConcernOptions::kWriteConcernField)) { // This command doesn't do writes so it should not be passed a writeConcern. - // If we did not use the default writeConcern, one was provided when it shouldn't have - // been by the user. auto responseBuilder = replyBuilder->getBodyBuilder(); CommandHelpers::appendCommandStatusNoThrow( responseBuilder, |