summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands.cpp
diff options
context:
space:
mode:
authorKevin Pulo <kevin.pulo@mongodb.com>2020-01-16 02:02:52 +0000
committerevergreen <evergreen@mongodb.com>2020-01-16 02:02:52 +0000
commitea0f5e7a4517404725aebbad5fb2ec2d53e5aa9f (patch)
tree376650f14c3f8426e09d50f22dc92f947e24dc22 /src/mongo/db/commands.cpp
parentdb5e7863b095355aae7a09b127d11de1bed1af33 (diff)
downloadmongo-ea0f5e7a4517404725aebbad5fb2ec2d53e5aa9f.tar.gz
SERVER-45098 test that RWC defaults are correctly applied to commands
Diffstat (limited to 'src/mongo/db/commands.cpp')
-rw-r--r--src/mongo/db/commands.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp
index 0df24b22613..b2c5fb809f8 100644
--- a/src/mongo/db/commands.cpp
+++ b/src/mongo/db/commands.cpp
@@ -347,7 +347,8 @@ BSONObj CommandHelpers::appendPassthroughFields(const BSONObj& cmdObjWithPassthr
return b.obj();
}
-BSONObj CommandHelpers::appendMajorityWriteConcern(const BSONObj& cmdObj) {
+BSONObj CommandHelpers::appendMajorityWriteConcern(const BSONObj& cmdObj,
+ WriteConcernOptions defaultWC) {
WriteConcernOptions newWC = kMajorityWriteConcern;
if (cmdObj.hasField(kWriteConcernField)) {
@@ -365,6 +366,13 @@ BSONObj CommandHelpers::appendMajorityWriteConcern(const BSONObj& cmdObj) {
WriteConcernOptions::SyncMode::UNSET,
wc["wtimeout"].Number());
}
+ } else if (!defaultWC.usedDefault) {
+ auto minimumAcceptableWTimeout = newWC.wTimeout;
+ newWC = defaultWC;
+ newWC.wMode = "majority";
+ if (defaultWC.wTimeout < minimumAcceptableWTimeout) {
+ newWC.wTimeout = minimumAcceptableWTimeout;
+ }
}
// Append all original fields except the writeConcern field to the new command.