summaryrefslogtreecommitdiff
path: root/src/mongo/db/write_concern.cpp
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2018-10-22 13:17:19 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2018-10-22 16:17:05 -0400
commit6d9c01b93fb94caf1b6c57bb00bfceb3e329ede9 (patch)
treeed535247e56c1dea323d14c242dd8cbd6dbd63c1 /src/mongo/db/write_concern.cpp
parent3b52f9b64914ee46593457a28771acc4cc542a14 (diff)
downloadmongo-6d9c01b93fb94caf1b6c57bb00bfceb3e329ede9.tar.gz
SERVER-34212 Config servers should only upconvert writeConcern to majority for requests on internal connections
Diffstat (limited to 'src/mongo/db/write_concern.cpp')
-rw-r--r--src/mongo/db/write_concern.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/db/write_concern.cpp b/src/mongo/db/write_concern.cpp
index 25b17a05343..ab14a5132f5 100644
--- a/src/mongo/db/write_concern.cpp
+++ b/src/mongo/db/write_concern.cpp
@@ -80,14 +80,14 @@ StatusWith<WriteConcernOptions> extractWriteConcern(OperationContext* opCtx,
WriteConcernOptions writeConcern = wcResult.getValue();
- if (writeConcern.usedDefault) {
- if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer &&
- !opCtx->getClient()->isInDirectClient()) {
- // This is here only for backwards compatibility with 3.2 clusters which have commands
- // that do not specify write concern when writing to the config server.
- writeConcern = {
- WriteConcernOptions::kMajority, WriteConcernOptions::SyncMode::UNSET, Seconds(30)};
- }
+ if (writeConcern.usedDefault && serverGlobalParams.clusterRole == ClusterRole::ConfigServer &&
+ !opCtx->getClient()->isInDirectClient() &&
+ (opCtx->getClient()->session()->getTags() | transport::Session::kInternalClient)) {
+ // Upconvert the writeConcern of any incoming requests from internal connections (i.e.,
+ // from other nodes in the clustser) to "majority." This protects against internal code
+ // that does not specify writeConcern when writing to the config server.
+ writeConcern = {
+ WriteConcernOptions::kMajority, WriteConcernOptions::SyncMode::UNSET, Seconds(30)};
} else {
Status wcStatus = validateWriteConcern(opCtx, writeConcern);
if (!wcStatus.isOK()) {