diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2014-12-09 11:21:50 -0500 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2014-12-10 18:33:41 -0500 |
commit | 98a7e7f9709413ce06f49b48dee98f7080505947 (patch) | |
tree | 967f77dd7247a37831d579e7a993c9b818ee20d8 /src/mongo/db/commands | |
parent | 8e3fe7f38c3d1ae8e072839bd4e2aaf78e19783c (diff) | |
download | mongo-98a7e7f9709413ce06f49b48dee98f7080505947.tar.gz |
SERVER-16500 Change the meaning of getReplicationMode() to be constant after start up.
Previously, ReplicationCoordinator::getReplicationMode() returned modeNone if
the settings object indicated the node was part of a replica set, but no valid
replica set configuration had yet been discovered. With this change, the
settings object is the sole determinant of the return value of
getReplicationMode(). Callers that wish to know if a replica set member is
initialized should instead check ReplicationCoordinator::getMemberState(). If
the value is RS_STARTUP, then the node is not initialized with a replica set
config.
This has the side-effect of removing the mutex in ReplCoordinatorImpl from the
code path for this method.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/compact.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 6 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp index 66d8f353e17..66d227ef66b 100644 --- a/src/mongo/db/commands/compact.cpp +++ b/src/mongo/db/commands/compact.cpp @@ -92,9 +92,7 @@ namespace mongo { } repl::ReplicationCoordinator* replCoord = repl::getGlobalReplicationCoordinator(); - if (replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeReplSet - && replCoord->getCurrentMemberState().primary() - && !cmdObj["force"].trueValue()) { + if (replCoord->getCurrentMemberState().primary() && !cmdObj["force"].trueValue()) { errmsg = "will not run compact on an active replica set primary as this is a slow blocking operation. use force:true to force"; return false; } diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index c9755ee3e38..455bebb06f7 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -1297,11 +1297,11 @@ namespace mongo { errmsg = "ns doesn't exist"; return false; } - repl::ReplicationCoordinator* replCoord = repl::getGlobalReplicationCoordinator(); - if (replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeReplSet - && state.isOnDisk()) { + if (state.isOnDisk()) { // this means that it will be doing a write operation, make sure we are on Master // ideally this check should be in slaveOk(), but at that point config is not known + repl::ReplicationCoordinator* const replCoord = + repl::getGlobalReplicationCoordinator(); if (!replCoord->canAcceptWritesForDatabase(dbname)) { errmsg = "not master"; return false; |