diff options
author | Wenbin Zhu <wenbin.zhu@mongodb.com> | 2021-03-16 00:27:22 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-16 23:47:35 +0000 |
commit | 0ae1138bbfc066c4c7eb9f857cf4e29447743a3c (patch) | |
tree | 5dcadb9f19db502adf41b1266e464ebdb6335b76 /src/mongo/db | |
parent | 915e8558215edb7775f47324a719061d54d02f44 (diff) | |
download | mongo-0ae1138bbfc066c4c7eb9f857cf4e29447743a3c.tar.gz |
SERVER-48179 Allow transition to SECONDARY at the end of rollback even it was changed to REMOVED.
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/repl/rollback_impl.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator.cpp | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp index c1ea618a6e5..2e1493b43e9 100644 --- a/src/mongo/db/repl/rollback_impl.cpp +++ b/src/mongo/db/repl/rollback_impl.cpp @@ -1225,8 +1225,12 @@ Status RollbackImpl::_triggerOpObserver(OperationContext* opCtx) { void RollbackImpl::_transitionFromRollbackToSecondary(OperationContext* opCtx) { invariant(opCtx); - invariant(_replicationCoordinator->getMemberState() == MemberState(MemberState::RS_ROLLBACK)); + // It is possible that this node has actually been removed due to a reconfig via + // heartbeat during rollback. But it should be fine to transition to SECONDARY + // and this won't change how the node reports its member state since topology + // coordinator will always check if the node exists in its local config when + // returning member state. LOGV2(21611, "Transition to SECONDARY"); ReplicationStateTransitionLockGuard transitionGuard(opCtx, MODE_X); diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp index ede2650481d..53ca6befcd1 100644 --- a/src/mongo/db/repl/topology_coordinator.cpp +++ b/src/mongo/db/repl/topology_coordinator.cpp @@ -1003,8 +1003,11 @@ HeartbeatResponseAction TopologyCoordinator::processHeartbeatResponse( nextAction = HeartbeatResponseAction::makeReconfigAction(); nextAction.setNextHeartbeatStartDate(nextHeartbeatStartDate); - // TODO(SERVER-48178) Only continue processing heartbeat in primary state to avoid - // concurrent reconfig and rollback. + // Only continue processing heartbeat in primary state. In other states it is not + // safe to continue processing heartbeat and should start reconfig right away. + // e.g. if this node was removed from replSet, _selfIndex is -1, and a following + // check on _selfIndex will keep retrying heartbeat to fetch new config, preventing + // the new config to be installed. if (_role != Role::kLeader) { return nextAction; } |