diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-10-31 20:22:29 -0400 |
---|---|---|
committer | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2018-11-06 13:33:31 -0500 |
commit | 1f40ed56b27d9c98c23eb601d6b06116b194dfe7 (patch) | |
tree | b2e84931ee561ccef91e93da5a920f41382b2830 /src | |
parent | 84df94224aa86213250fa7e5e8d3a1ca6a71ac1b (diff) | |
download | mongo-1f40ed56b27d9c98c23eb601d6b06116b194dfe7.tar.gz |
SERVER-37557 Add startup warning about enableMajorityReadConcern and usage of arbiters
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/repl_set_config.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/repl/repl_set_config.h | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 11 |
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 f3dfccc5052..0ae3ca2635d 100644 --- a/src/mongo/db/repl/repl_set_config.cpp +++ b/src/mongo/db/repl/repl_set_config.cpp @@ -859,5 +859,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 65976c2a658..b4dabc42479 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 77ebaefdfa3..488ee1a8996 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -578,6 +578,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(); |