summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands
diff options
context:
space:
mode:
authorHuayu Ouyang <huayu.ouyang@mongodb.com>2021-04-19 14:49:20 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-20 20:25:09 +0000
commit18e68c396861ea92dffe80bb7d3ca3efb5ece037 (patch)
treeec234648073f5f02c626f65a14cf384cc9134cde /src/mongo/s/commands
parent89e2a97e9ff9c42a1a10ea3e1fcd6c5fbe3b0dfb (diff)
downloadmongo-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.cpp34
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);
+ }
}
}