diff options
author | Huayu Ouyang <huayu.ouyang@mongodb.com> | 2021-04-19 14:49:20 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-20 20:25:09 +0000 |
commit | 18e68c396861ea92dffe80bb7d3ca3efb5ece037 (patch) | |
tree | ec234648073f5f02c626f65a14cf384cc9134cde /src/mongo/s/commands | |
parent | 89e2a97e9ff9c42a1a10ea3e1fcd6c5fbe3b0dfb (diff) | |
download | mongo-18e68c396861ea92dffe80bb7d3ca3efb5ece037.tar.gz |
SERVER-55699 Add an explicit write concern to internal write operations
Diffstat (limited to 'src/mongo/s/commands')
-rw-r--r-- | src/mongo/s/commands/strategy.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp index 073ba3231fe..c01ba3c220c 100644 --- a/src/mongo/s/commands/strategy.cpp +++ b/src/mongo/s/commands/strategy.cpp @@ -652,19 +652,27 @@ Status ParseAndRunCommand::RunInvocation::_setup() { if (supportsWriteConcern && !clientSuppliedWriteConcern && (!TransactionRouter::get(opCtx) || isTransactionCommand(_parc->_commandName)) && - !opCtx->getClient()->isInDirectClient() && !isInternalClient) { - // This command is not from a DBDirectClient or internal client, and supports WC, but - // wasn't given one - so apply the default, if there is one. - if (const auto wcDefault = ReadWriteConcernDefaults::get(opCtx->getServiceContext()) - .getDefaultWriteConcern(opCtx)) { - _parc->_wc = *wcDefault; - customDefaultWriteConcernWasApplied = true; - LOGV2_DEBUG(22766, - 2, - "Applying default writeConcern on {command} of {writeConcern}", - "Applying default writeConcern on command", - "command"_attr = request.getCommandName(), - "writeConcern"_attr = *wcDefault); + !opCtx->getClient()->isInDirectClient()) { + if (isInternalClient) { + tassert( + 5569901, + "received command without explicit writeConcern on an internalClient connection {}"_format( + redact(request.body.toString())), + request.body.hasField(WriteConcernOptions::kWriteConcernField)); + } else { + // This command is not from a DBDirectClient or internal client, and supports WC, but + // wasn't given one - so apply the default, if there is one. + if (const auto wcDefault = ReadWriteConcernDefaults::get(opCtx->getServiceContext()) + .getDefaultWriteConcern(opCtx)) { + _parc->_wc = *wcDefault; + customDefaultWriteConcernWasApplied = true; + LOGV2_DEBUG(22766, + 2, + "Applying default writeConcern on {command} of {writeConcern}", + "Applying default writeConcern on command", + "command"_attr = request.getCommandName(), + "writeConcern"_attr = *wcDefault); + } } } |