summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@10gen.com>2018-10-31 20:22:29 -0400
committerVesselina Ratcheva <vesselina.ratcheva@10gen.com>2018-11-19 18:16:34 -0500
commitac99b600745b488968257d936d8fad0f755c4f1c (patch)
tree09550b2a8e836944dd633276ad2a031f5afb8b7c
parenta51c150ae5eff8240e2fcc2f6f1e09b9a296f1a2 (diff)
downloadmongo-ac99b600745b488968257d936d8fad0f755c4f1c.tar.gz
SERVER-37557 Add startup warning about enableMajorityReadConcern and usage of arbiters
(cherry picked from commit 1f40ed56b27d9c98c23eb601d6b06116b194dfe7)
-rw-r--r--src/mongo/db/repl/repl_set_config.cpp9
-rw-r--r--src/mongo/db/repl/repl_set_config.h5
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp11
3 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/repl/repl_set_config.cpp b/src/mongo/db/repl/repl_set_config.cpp
index 6917253e196..1c6cedbdbda 100644
--- a/src/mongo/db/repl/repl_set_config.cpp
+++ b/src/mongo/db/repl/repl_set_config.cpp
@@ -869,5 +869,14 @@ int ReplSetConfig::calculatePriorityRank(double priority) const {
return count;
}
+bool ReplSetConfig::containsArbiter() const {
+ for (MemberIterator mem = membersBegin(); mem != membersEnd(); mem++) {
+ if (mem->isArbiter()) {
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace repl
} // namespace mongo
diff --git a/src/mongo/db/repl/repl_set_config.h b/src/mongo/db/repl/repl_set_config.h
index 53621d2e6df..bdcbe58d3ab 100644
--- a/src/mongo/db/repl/repl_set_config.h
+++ b/src/mongo/db/repl/repl_set_config.h
@@ -358,6 +358,11 @@ public:
*/
int calculatePriorityRank(double priority) const;
+ /**
+ * Returns true if this replica set has at least one arbiter.
+ */
+ bool containsArbiter() const;
+
private:
/**
* Parses the "settings" subdocument of a replica set configuration.
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index be73f59bacf..5ddda1bc260 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -572,6 +572,17 @@ void ReplicationCoordinatorImpl::_finishLoadLocalConfig(
myIndex = StatusWith<int>(-1);
}
+ if (serverGlobalParams.enableMajorityReadConcern && localConfig.containsArbiter()) {
+ log() << startupWarningsLog;
+ log() << "** WARNING: This replica set uses arbiters, but readConcern:majority is enabled "
+ << startupWarningsLog;
+ log() << "** for this node. This is not a recommended configuration. Please see "
+ << startupWarningsLog;
+ log() << "** https://dochub.mongodb.org/core/psa-disable-rc-majority"
+ << startupWarningsLog;
+ log() << startupWarningsLog;
+ }
+
// Do not check optime, if this node is an arbiter.
bool isArbiter =
myIndex.getValue() != -1 && localConfig.getMemberAt(myIndex.getValue()).isArbiter();