summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp
diff options
context:
space:
mode:
authorGabriel Marks <gabriel.marks@mongodb.com>2022-01-18 15:12:06 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-18 16:26:20 +0000
commit4c96930ccb001d91fd188380f80756c19f1ad3c1 (patch)
tree9961263123e2878b6ebd0287ec94ccfff326ef7a /src/mongo/s/commands/cluster_rwc_defaults_commands.cpp
parentf857a8efec9cde7a8c6ee903043e2cd4b5396d48 (diff)
downloadmongo-4c96930ccb001d91fd188380f80756c19f1ad3c1.tar.gz
SERVER-60817 Check write concern string for validity
Diffstat (limited to 'src/mongo/s/commands/cluster_rwc_defaults_commands.cpp')
-rw-r--r--src/mongo/s/commands/cluster_rwc_defaults_commands.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp
index abb36e4ab89..6bf1755941d 100644
--- a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp
+++ b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/commands/rwc_defaults_commands_gen.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/read_write_concern_defaults.h"
+#include "mongo/logv2/log.h"
#include "mongo/s/cluster_commands_helpers.h"
#include "mongo/s/grid.h"
@@ -70,6 +71,16 @@ public:
// Quickly pick up the new defaults by setting them in the cache.
auto newDefaults = RWConcernDefault::parse(
IDLParserErrorContext("ClusterSetDefaultRWConcern"), cmdResponse.response);
+ if (auto optWC = newDefaults.getDefaultWriteConcern()) {
+ if (optWC->writeModeIsCustom()) {
+ LOGV2_WARNING(
+ 6081700,
+ "A custom write concern is being set as the default write concern in a sharded "
+ "cluster. This set is unchecked, but if the custom write concern does not "
+ "exist on all shards in the cluster, errors will occur upon writes",
+ "customWriteConcern"_attr = optWC->wMode);
+ }
+ }
ReadWriteConcernDefaults::get(opCtx).setDefault(opCtx, std::move(newDefaults));
CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.response, &result);