From fd0aac9d3f762520c6159a2335c70194fb62148e Mon Sep 17 00:00:00 2001 From: Vesselina Ratcheva Date: Wed, 31 Oct 2018 20:22:29 -0400 Subject: SERVER-37557 Add startup warning about enableMajorityReadConcern and usage of arbiters (cherry picked from commit 1f40ed56b27d9c98c23eb601d6b06116b194dfe7) --- src/mongo/db/repl/repl_set_config.cpp | 9 +++++++++ src/mongo/db/repl/repl_set_config.h | 5 +++++ src/mongo/db/repl/replication_coordinator_impl.cpp | 11 +++++++++++ 3 files changed, 25 insertions(+) (limited to 'src') 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(-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(); -- cgit v1.2.1