summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp
diff options
context:
space:
mode:
authorMedha Potluri <medha.potluri@mongodb.com>2019-07-09 15:02:13 -0400
committerMedha Potluri <medha.potluri@mongodb.com>2019-08-13 12:28:28 -0400
commitd14ee9513924f63572324debc7721ca2ef93c22f (patch)
treebd9f1c5a1f5e2ca40287d8e2731b94dde91133ce /src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp
parent0265512bc30a8f45231bb02e63ce3251e9d185dd (diff)
downloadmongo-d14ee9513924f63572324debc7721ca2ef93c22f.tar.gz
SERVER-41503 Track the target opTime for catchup in replSetStatus on primaries
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp
index 2b7d7bd62f9..ea12a516ba1 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp
@@ -64,6 +64,10 @@ public:
if (_replCoord->_electionFinishedEvent.isValid()) {
_replCoord->_replExecutor->signalEvent(_replCoord->_electionFinishedEvent);
}
+
+ // Clear the node's election candidate metrics if it loses either the dry-run or actual
+ // election, since it will not become primary.
+ ReplicationMetrics::get(getGlobalServiceContext()).clearElectionCandidateMetrics();
}
void dismiss() {
@@ -141,6 +145,9 @@ void ReplicationCoordinatorImpl::_startElectSelfV1_inlock(
long long term = _topCoord->getTerm();
int primaryIndex = -1;
+ Date_t now = _replExecutor->now();
+ ReplicationMetrics::get(getServiceContext()).setElectionCandidateMetrics(now);
+
if (reason == TopologyCoordinator::StartElectionReason::kStepUpRequestSkipDryRun) {
long long newTerm = term + 1;
log() << "skipping dry run and running for election in term " << newTerm;