summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands/strategy.cpp
diff options
context:
space:
mode:
authorHuayu Ouyang <huayu.ouyang@mongodb.com>2021-04-07 21:17:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-19 23:44:19 +0000
commit49d2a22fc712873c26d4daf387b116ea50a1c2c5 (patch)
treec597bfd34499197659728b3318433377c9bff9f1 /src/mongo/s/commands/strategy.cpp
parent3fa7f2ae9aad0e9754209fcbcc45851b8acc7b40 (diff)
downloadmongo-49d2a22fc712873c26d4daf387b116ea50a1c2c5.tar.gz
SERVER-55700 Update kImplicitDefault in WriteConcernOptions
Diffstat (limited to 'src/mongo/s/commands/strategy.cpp')
-rw-r--r--src/mongo/s/commands/strategy.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 814befda717..073ba3231fe 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -646,10 +646,15 @@ Status ParseAndRunCommand::RunInvocation::_setup() {
bool clientSuppliedWriteConcern = !_parc->_wc->usedDefault;
bool customDefaultWriteConcernWasApplied = false;
+ bool isInternalClient =
+ (opCtx->getClient()->session() &&
+ (opCtx->getClient()->session()->getTags() & transport::Session::kInternalClient));
if (supportsWriteConcern && !clientSuppliedWriteConcern &&
- (!TransactionRouter::get(opCtx) || isTransactionCommand(_parc->_commandName))) {
- // This command supports WC, but wasn't given one - so apply the default, if there is one.
+ (!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;
@@ -685,6 +690,8 @@ Status ParseAndRunCommand::RunInvocation::_setup() {
provenance.setSource(ReadWriteConcernProvenance::Source::clientSupplied);
} else if (customDefaultWriteConcernWasApplied) {
provenance.setSource(ReadWriteConcernProvenance::Source::customDefault);
+ } else if (opCtx->getClient()->isInDirectClient() || isInternalClient) {
+ provenance.setSource(ReadWriteConcernProvenance::Source::internalWriteDefault);
} else {
provenance.setSource(ReadWriteConcernProvenance::Source::implicitDefault);
}