summaryrefslogtreecommitdiff
path: root/src
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:00:29 -0500
commitfd0aac9d3f762520c6159a2335c70194fb62148e (patch)
treec897c2caa2b94bbe3330b6fa6634d065f882d23a /src
parent4ca136a772111d80c6667209574d9c43146ba2e7 (diff)
downloadmongo-fd0aac9d3f762520c6159a2335c70194fb62148e.tar.gz
SERVER-37557 Add startup warning about enableMajorityReadConcern and usage of arbiters
(cherry picked from commit 1f40ed56b27d9c98c23eb601d6b06116b194dfe7)
Diffstat (limited to 'src')
-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 b3f6b11ca36..32d00083d82 100644
--- a/src/mongo/db/repl/repl_set_config.cpp
+++ b/src/mongo/db/repl/repl_set_config.cpp
@@ -872,5 +872,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 30d963173a1..d8f0b0d511b 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 14e1e0b6406..b5794a0b93f 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -560,6 +560,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();