diff options
author | Esha Maharishi <esha.maharishi@mongodb.com> | 2018-10-22 13:17:19 -0400 |
---|---|---|
committer | Esha Maharishi <esha.maharishi@mongodb.com> | 2018-10-22 16:17:05 -0400 |
commit | 6d9c01b93fb94caf1b6c57bb00bfceb3e329ede9 (patch) | |
tree | ed535247e56c1dea323d14c242dd8cbd6dbd63c1 /src/mongo/db/write_concern.cpp | |
parent | 3b52f9b64914ee46593457a28771acc4cc542a14 (diff) | |
download | mongo-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.cpp | 16 |
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()) { |