diff options
author | Benety Goh <benety@mongodb.com> | 2015-06-04 16:06:36 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2015-06-09 12:38:31 -0400 |
commit | acc78660cf97acfdb85bb0fd641d14f6d6c29741 (patch) | |
tree | e2257841ed44b232a5b1cb6a94e5dd49392ef42b /src/mongo/db | |
parent | a0f7f8ca367dcb79f5dd5c6a62b32876144e6eef (diff) | |
download | mongo-acc78660cf97acfdb85bb0fd641d14f6d6c29741.tar.gz |
SERVER-18807 close all connections when transitioning replication member state to ROLLBACK
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 8f878067129..cb11301a1a9 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -2050,8 +2050,9 @@ namespace { } return kActionNone; } + PostMemberStateUpdateAction result; - if (_memberState.primary() || newState.removed()) { + if (_memberState.primary() || newState.removed() || newState.rollback()) { // Wake up any threads blocked in awaitReplication, close connections, etc. for (std::vector<WaiterInfo*>::iterator it = _replicationWaiterList.begin(); it != _replicationWaiterList.end(); ++it) { @@ -2064,16 +2065,18 @@ namespace { result = kActionCloseAllConnections; } else { - if (_memberState.secondary() && !newState.primary()) { - // Switching out of SECONDARY, but not to PRIMARY. - _canServeNonLocalReads.store(0U); - } - else if (newState.secondary()) { - // Switching into SECONDARY, but not from PRIMARY. - _canServeNonLocalReads.store(1U); - } result = kActionFollowerModeStateChange; } + + if (_memberState.secondary() && !newState.primary()) { + // Switching out of SECONDARY, but not to PRIMARY. + _canServeNonLocalReads.store(0U); + } + else if (!_memberState.primary() && newState.secondary()) { + // Switching into SECONDARY, but not from PRIMARY. + _canServeNonLocalReads.store(1U); + } + if (newState.secondary() && _topCoord->getRole() == TopologyCoordinator::Role::candidate) { // When transitioning to SECONDARY, the only way for _topCoord to report the candidate // role is if the configuration represents a single-node replica set. In that case, the |