From a78f546ff0caab8c33738aa922a294d9143a5397 Mon Sep 17 00:00:00 2001 From: Siyuan Zhou Date: Sun, 24 Feb 2019 01:30:41 -0500 Subject: SERVER-39367 Advance commit point when it has the same term as the last applied - Reverted SERVER-33248 "Allow choosing a sync source that we are up to date with if it has a higher lastOpCommitted". - Reverted the logic change of SERVER-27123 "Only update commit point via spanning tree". - Added the term check when advancing commit point and added unit tests. --- src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp') diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp index 5bb5f344457..1961f7f2f99 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp @@ -148,7 +148,6 @@ void ReplicationCoordinatorImpl::_handleHeartbeatResponse( } ReplSetHeartbeatResponse hbResponse; - OpTime lastOpCommitted; BSONObj resp; if (responseStatus.isOK()) { resp = cbData.response.data; @@ -177,12 +176,8 @@ void ReplicationCoordinatorImpl::_handleHeartbeatResponse( replMetadata = responseStatus; } if (replMetadata.isOK()) { - lastOpCommitted = replMetadata.getValue().getLastOpCommitted(); + _advanceCommitPoint(lk, replMetadata.getValue().getLastOpCommitted()); - // Arbiters are the only nodes allowed to advance their commit point via heartbeats. - if (_getMemberState_inlock().arbiter()) { - _advanceCommitPoint(lk, lastOpCommitted); - } // Asynchronous stepdown could happen, but it will wait for _mutex and execute // after this function, so we cannot and don't need to wait for it to finish. _processReplSetMetadata_inlock(replMetadata.getValue()); @@ -211,8 +206,8 @@ void ReplicationCoordinatorImpl::_handleHeartbeatResponse( hbStatusResponse = StatusWith(responseStatus); } - HeartbeatResponseAction action = _topCoord->processHeartbeatResponse( - now, networkTime, target, hbStatusResponse, lastOpCommitted); + HeartbeatResponseAction action = + _topCoord->processHeartbeatResponse(now, networkTime, target, hbStatusResponse); if (action.getAction() == HeartbeatResponseAction::NoAction && hbStatusResponse.isOK() && hbStatusResponse.getValue().hasState() && -- cgit v1.2.1