summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2019-02-24 01:30:41 -0500
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2019-02-26 20:50:59 -0500
commita78f546ff0caab8c33738aa922a294d9143a5397 (patch)
treef3a14d4d066319602f7e974d01c585c157c8144b /src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
parent135a2a0a2a5b5b95e20bb83d9626036f946ba735 (diff)
downloadmongo-a78f546ff0caab8c33738aa922a294d9143a5397.tar.gz
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.
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp11
1 files changed, 3 insertions, 8 deletions
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<ReplSetHeartbeatResponse>(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() &&