diff options
Diffstat (limited to 'src/mongo/db/repl')
7 files changed, 150 insertions, 38 deletions
diff --git a/src/mongo/db/repl/election_reason_counter.h b/src/mongo/db/repl/election_reason_counter.h index 8dd068181b5..801d9855a45 100644 --- a/src/mongo/db/repl/election_reason_counter.h +++ b/src/mongo/db/repl/election_reason_counter.h @@ -41,11 +41,17 @@ class ElectionReasonCounter : public ElectionReasonCounterBase { public: using ElectionReasonCounterBase::getCalled; using ElectionReasonCounterBase::setCalled; + using ElectionReasonCounterBase::getSuccessful; + using ElectionReasonCounterBase::setSuccessful; void incrementCalled() { setCalled(getCalled() + 1); } + void incrementSuccessful() { + setSuccessful(getSuccessful() + 1); + } + ElectionReasonCounter parse(const IDLParserErrorContext& ctxt, const BSONObj& bsonObject); }; diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index 18636ca66f5..d7000f33f35 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -1032,12 +1032,14 @@ private: * This job will be scheduled to run in DB worker threads. */ void _writeLastVoteForMyElection(LastVote lastVote, - const executor::TaskExecutor::CallbackArgs& cbData); + const executor::TaskExecutor::CallbackArgs& cbData, + TopologyCoordinator::StartElectionReason reason); /** * Starts VoteRequester to run the real election when last vote write has completed. */ - void _startVoteRequester_inlock(long long newTerm); + void _startVoteRequester_inlock(long long newTerm, + TopologyCoordinator::StartElectionReason reason); /** * Callback called when the VoteRequester has completed; checks the results and @@ -1045,7 +1047,8 @@ private: * "originalTerm" was the term during which the election began, if the term has since * changed, do not step up as primary. */ - void _onVoteRequestComplete(long long originalTerm); + void _onVoteRequestComplete(long long originalTerm, + TopologyCoordinator::StartElectionReason reason); /** * Removes 'host' from the sync source blacklist. If 'host' isn't found, it's simply 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 b93ba668eb1..2b7d7bd62f9 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp @@ -233,8 +233,8 @@ void ReplicationCoordinatorImpl::_startRealElection_inlock( LastVote lastVote{newTerm, _selfIndex}; auto cbStatus = _replExecutor->scheduleWork( - [this, lastVote](const executor::TaskExecutor::CallbackArgs& cbData) { - _writeLastVoteForMyElection(lastVote, cbData); + [this, lastVote, reason](const executor::TaskExecutor::CallbackArgs& cbData) { + _writeLastVoteForMyElection(lastVote, cbData, reason); }); if (cbStatus.getStatus() == ErrorCodes::ShutdownInProgress) { return; @@ -244,7 +244,9 @@ void ReplicationCoordinatorImpl::_startRealElection_inlock( } void ReplicationCoordinatorImpl::_writeLastVoteForMyElection( - LastVote lastVote, const executor::TaskExecutor::CallbackArgs& cbData) { + LastVote lastVote, + const executor::TaskExecutor::CallbackArgs& cbData, + TopologyCoordinator::StartElectionReason reason) { // storeLocalLastVoteDocument can call back in to the replication coordinator, // so _mutex must be unlocked here. However, we cannot return until we // lock it because we want to lose the election on cancel or error and @@ -276,13 +278,14 @@ void ReplicationCoordinatorImpl::_writeLastVoteForMyElection( << lastVote.getTerm() << ", current term: " << _topCoord->getTerm(); return; } - _startVoteRequester_inlock(lastVote.getTerm()); + _startVoteRequester_inlock(lastVote.getTerm(), reason); _replExecutor->signalEvent(_electionDryRunFinishedEvent); lossGuard.dismiss(); } -void ReplicationCoordinatorImpl::_startVoteRequester_inlock(long long newTerm) { +void ReplicationCoordinatorImpl::_startVoteRequester_inlock( + long long newTerm, TopologyCoordinator::StartElectionReason reason) { const auto lastOpTime = _getMyLastAppliedOpTime_inlock(); _voteRequester.reset(new VoteRequester); @@ -293,15 +296,17 @@ void ReplicationCoordinatorImpl::_startVoteRequester_inlock(long long newTerm) { } fassert(28643, nextPhaseEvh.getStatus()); _replExecutor - ->onEvent( - nextPhaseEvh.getValue(), - [=](const executor::TaskExecutor::CallbackArgs&) { _onVoteRequestComplete(newTerm); }) + ->onEvent(nextPhaseEvh.getValue(), + [=](const executor::TaskExecutor::CallbackArgs&) { + _onVoteRequestComplete(newTerm, reason); + }) .status_with_transitional_ignore(); } MONGO_FAIL_POINT_DEFINE(electionHangsBeforeUpdateMemberState); -void ReplicationCoordinatorImpl::_onVoteRequestComplete(long long newTerm) { +void ReplicationCoordinatorImpl::_onVoteRequestComplete( + long long newTerm, TopologyCoordinator::StartElectionReason reason) { stdx::lock_guard<stdx::mutex> lk(_mutex); LoseElectionGuardV1 lossGuard(this); @@ -325,6 +330,8 @@ void ReplicationCoordinatorImpl::_onVoteRequestComplete(long long newTerm) { return; case VoteRequester::Result::kSuccessfullyElected: log() << "election succeeded, assuming primary role in term " << _topCoord->getTerm(); + ReplicationMetrics::get(getServiceContext()) + .incrementNumElectionsSuccessfulForReason(reason); break; case VoteRequester::Result::kPrimaryRespondedNo: // This is impossible because we would only require the primary's diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp index 27bd7a4653d..00e6aab8daa 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp @@ -276,15 +276,21 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenAllNodesVoteYea) { stopCapturingLogMessages(); ASSERT_EQUALS(1, countLogLinesContaining("election succeeded")); - // Check that the numElectionTimeoutsCalled election metric has been incremented, and that none - // of the metrics that track the number of elections called for other reasons has been - // incremented. + // Check that the numElectionTimeoutsCalled and the numElectionTimeoutsSuccessful election + // metrics have been incremented, and that none of the metrics that track the number of + // elections called or successful for other reasons has been incremented. ServiceContext* svcCtx = getServiceContext(); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversCalled_forTesting()); ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsCalled_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsSuccessful_forTesting()); + ASSERT_EQUALS(0, + ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsSuccessful_forTesting()); } TEST_F(ReplCoordTest, ElectionSucceedsWhenMaxSevenNodesVoteYea) { @@ -1495,15 +1501,21 @@ TEST_F(TakeoverTest, SuccessfulCatchupTakeover) { TopologyCoordinator::StartElectionReason::kCatchupTakeover, lastVoteExpected); - // Check that the numCatchUpTakeoversCalled election metric has been incremented, and that none - // of the metrics that track the number of elections called for other reasons has been - // incremented. + // Check that the numCatchUpTakeoversCalled and the numCatchUpTakeoversSuccessful election + // metrics have been incremented, and that none of the metrics that track the number of + // elections called or successful for other reasons has been incremented. ServiceContext* svcCtx = getServiceContext(); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversCalled_forTesting()); ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsCalled_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsSuccessful_forTesting()); + ASSERT_EQUALS(0, + ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsSuccessful_forTesting()); } TEST_F(TakeoverTest, CatchupTakeoverDryRunFailsPrimarySaysNo) { @@ -1862,15 +1874,21 @@ TEST_F(TakeoverTest, SuccessfulPriorityTakeover) { TopologyCoordinator::StartElectionReason::kPriorityTakeover, lastVoteExpected); - // Check that the numPriorityTakeoversCalled election metric has been incremented, and that none - // of the metrics that track the number of elections called for other reasons has been - // incremented. + // Check that the numPriorityTakeoversCalled and the numPriorityTakeoversSuccessful election + // metrics have been incremented, and that none of the metrics that track the number of + // elections called or successful for other reasons has been incremented. ServiceContext* svcCtx = getServiceContext(); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsCalled_forTesting()); ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsCalled_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsSuccessful_forTesting()); + ASSERT_EQUALS(1, + ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsSuccessful_forTesting()); } TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedSameSecond) { diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index 23d36dbc802..a87592ee944 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -2319,15 +2319,21 @@ TEST_F(ReplCoordTest, SingleNodeReplSetUnfreeze) { getNet()->exitNetwork(); ASSERT_TRUE(getReplCoord()->getMemberState().primary()); - // Check that the numFreezeTimeoutsCalled election metric has been incremented, and that none - // of the metrics that track the number of elections called for other reasons has been - // incremented. + // Check that the numFreezeTimeoutsCalled and the numFreezeTimeoutsSuccessful election metrics + // have been incremented, and that none of the metrics that track the number of elections called + // or successful for other reasons has been incremented. ServiceContext* svcCtx = getServiceContext(); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsCalled_forTesting()); ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsCalled_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsSuccessful_forTesting()); + ASSERT_EQUALS(0, + ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsSuccessful_forTesting()); + ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsSuccessful_forTesting()); } TEST_F(ReplCoordTest, NodeBecomesPrimaryAgainWhenStepDownTimeoutExpiresInASingleNodeSet) { @@ -2344,15 +2350,21 @@ TEST_F(ReplCoordTest, NodeBecomesPrimaryAgainWhenStepDownTimeoutExpiresInASingle auto opCtx = makeOperationContext(); runSingleNodeElection(opCtx.get()); - // Check that the numElectionTimeoutsCalled election metric has been incremented, and that none - // of the metrics that track the number of elections called for other reasons has been - // incremented. + // Check that the numElectionTimeoutsCalled and the numElectionTimeoutsSuccessful election + // metrics have been incremented, and that none of the metrics that track the number of + // elections called or successful for other reasons has been incremented. ServiceContext* svcCtx = getServiceContext(); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversCalled_forTesting()); ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsCalled_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsSuccessful_forTesting()); + ASSERT_EQUALS(0, + ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsSuccessful_forTesting()); getReplCoord()->stepDown(opCtx.get(), true, Milliseconds(0), Milliseconds(1000)); getNet()->enterNetwork(); // Must do this before inspecting the topocoord @@ -2369,15 +2381,22 @@ TEST_F(ReplCoordTest, NodeBecomesPrimaryAgainWhenStepDownTimeoutExpiresInASingle getNet()->exitNetwork(); ASSERT_TRUE(getReplCoord()->getMemberState().primary()); - // Check that the numFreezeTimeoutsCalled election metric has been incremented, and that none - // of the metrics that track the number of elections called for other reasons has been - // incremented. When a stepdown timeout expires in a single node replica set, an election is - // called for the same reason as is used when a freeze timeout expires. + // Check that the numFreezeTimeoutsCalled and the numFreezeTimeoutsSuccessful election metrics + // have been incremented, and that none of the metrics that track the number of elections called + // or successful for other reasons has been incremented. When a stepdown timeout expires in a + // single node replica set, an election is called for the same reason as is used when a freeze + // timeout expires. ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversCalled_forTesting()); ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversCalled_forTesting()); ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsCalled_forTesting()); ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsCalled_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumStepUpCmdsSuccessful_forTesting()); + ASSERT_EQUALS(0, + ReplicationMetrics::get(svcCtx).getNumPriorityTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(0, ReplicationMetrics::get(svcCtx).getNumCatchUpTakeoversSuccessful_forTesting()); + ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumElectionTimeoutsSuccessful_forTesting()); + ASSERT_EQUALS(1, ReplicationMetrics::get(svcCtx).getNumFreezeTimeoutsSuccessful_forTesting()); } TEST_F( diff --git a/src/mongo/db/repl/replication_metrics.cpp b/src/mongo/db/repl/replication_metrics.cpp index acbd02ade83..8cdc1405827 100644 --- a/src/mongo/db/repl/replication_metrics.cpp +++ b/src/mongo/db/repl/replication_metrics.cpp @@ -64,31 +64,59 @@ void ReplicationMetrics::incrementNumElectionsCalledForReason( case TopologyCoordinator::StartElectionReason::kStepUpRequestSkipDryRun: { ElectionReasonCounter& stepUpCmd = _electionMetrics.getStepUpCmd(); stepUpCmd.incrementCalled(); - _electionMetrics.setStepUpCmd(stepUpCmd); break; } case TopologyCoordinator::StartElectionReason::kPriorityTakeover: { ElectionReasonCounter& priorityTakeover = _electionMetrics.getPriorityTakeover(); priorityTakeover.incrementCalled(); - _electionMetrics.setPriorityTakeover(priorityTakeover); break; } case TopologyCoordinator::StartElectionReason::kCatchupTakeover: { ElectionReasonCounter& catchUpTakeover = _electionMetrics.getCatchUpTakeover(); catchUpTakeover.incrementCalled(); - _electionMetrics.setCatchUpTakeover(catchUpTakeover); break; } case TopologyCoordinator::StartElectionReason::kElectionTimeout: { ElectionReasonCounter& electionTimeout = _electionMetrics.getElectionTimeout(); electionTimeout.incrementCalled(); - _electionMetrics.setElectionTimeout(electionTimeout); break; } case TopologyCoordinator::StartElectionReason::kSingleNodePromptElection: { ElectionReasonCounter& freezeTimeout = _electionMetrics.getFreezeTimeout(); freezeTimeout.incrementCalled(); - _electionMetrics.setFreezeTimeout(freezeTimeout); + break; + } + } +} + +void ReplicationMetrics::incrementNumElectionsSuccessfulForReason( + TopologyCoordinator::StartElectionReason reason) { + stdx::lock_guard<stdx::mutex> lk(_mutex); + switch (reason) { + case TopologyCoordinator::StartElectionReason::kStepUpRequest: + case TopologyCoordinator::StartElectionReason::kStepUpRequestSkipDryRun: { + ElectionReasonCounter& stepUpCmd = _electionMetrics.getStepUpCmd(); + stepUpCmd.incrementSuccessful(); + break; + } + case TopologyCoordinator::StartElectionReason::kPriorityTakeover: { + ElectionReasonCounter& priorityTakeover = _electionMetrics.getPriorityTakeover(); + priorityTakeover.incrementSuccessful(); + break; + } + case TopologyCoordinator::StartElectionReason::kCatchupTakeover: { + ElectionReasonCounter& catchUpTakeover = _electionMetrics.getCatchUpTakeover(); + catchUpTakeover.incrementSuccessful(); + break; + } + case TopologyCoordinator::StartElectionReason::kElectionTimeout: { + ElectionReasonCounter& electionTimeout = _electionMetrics.getElectionTimeout(); + electionTimeout.incrementSuccessful(); + break; + } + case TopologyCoordinator::StartElectionReason::kSingleNodePromptElection: { + ElectionReasonCounter& freezeTimeout = _electionMetrics.getFreezeTimeout(); + freezeTimeout.incrementSuccessful(); break; } } @@ -125,9 +153,29 @@ int ReplicationMetrics::getNumFreezeTimeoutsCalled_forTesting() { return _electionMetrics.getFreezeTimeout().getCalled(); } -BSONObj ReplicationMetrics::getElectionMetricsBSON() { +int ReplicationMetrics::getNumStepUpCmdsSuccessful_forTesting() { stdx::lock_guard<stdx::mutex> lk(_mutex); - return _electionMetrics.toBSON(); + return _electionMetrics.getStepUpCmd().getSuccessful(); +} + +int ReplicationMetrics::getNumPriorityTakeoversSuccessful_forTesting() { + stdx::lock_guard<stdx::mutex> lk(_mutex); + return _electionMetrics.getPriorityTakeover().getSuccessful(); +} + +int ReplicationMetrics::getNumCatchUpTakeoversSuccessful_forTesting() { + stdx::lock_guard<stdx::mutex> lk(_mutex); + return _electionMetrics.getCatchUpTakeover().getSuccessful(); +} + +int ReplicationMetrics::getNumElectionTimeoutsSuccessful_forTesting() { + stdx::lock_guard<stdx::mutex> lk(_mutex); + return _electionMetrics.getElectionTimeout().getSuccessful(); +} + +int ReplicationMetrics::getNumFreezeTimeoutsSuccessful_forTesting() { + stdx::lock_guard<stdx::mutex> lk(_mutex); + return _electionMetrics.getFreezeTimeout().getSuccessful(); } int ReplicationMetrics::getNumStepDownsCausedByHigherTerm_forTesting() { @@ -135,6 +183,11 @@ int ReplicationMetrics::getNumStepDownsCausedByHigherTerm_forTesting() { return _electionMetrics.getNumStepDownsCausedByHigherTerm(); } +BSONObj ReplicationMetrics::getElectionMetricsBSON() { + stdx::lock_guard<stdx::mutex> lk(_mutex); + return _electionMetrics.toBSON(); +} + class ReplicationMetrics::ElectionMetricsSSS : public ServerStatusSection { public: ElectionMetricsSSS() : ServerStatusSection("electionMetrics") {} diff --git a/src/mongo/db/repl/replication_metrics.h b/src/mongo/db/repl/replication_metrics.h index b893bea1959..564be3b08dd 100644 --- a/src/mongo/db/repl/replication_metrics.h +++ b/src/mongo/db/repl/replication_metrics.h @@ -49,6 +49,7 @@ public: ~ReplicationMetrics(); void incrementNumElectionsCalledForReason(TopologyCoordinator::StartElectionReason reason); + void incrementNumElectionsSuccessfulForReason(TopologyCoordinator::StartElectionReason reason); void incrementNumStepDownsCausedByHigherTerm(); int getNumStepUpCmdsCalled_forTesting(); @@ -56,6 +57,11 @@ public: int getNumCatchUpTakeoversCalled_forTesting(); int getNumElectionTimeoutsCalled_forTesting(); int getNumFreezeTimeoutsCalled_forTesting(); + int getNumStepUpCmdsSuccessful_forTesting(); + int getNumPriorityTakeoversSuccessful_forTesting(); + int getNumCatchUpTakeoversSuccessful_forTesting(); + int getNumElectionTimeoutsSuccessful_forTesting(); + int getNumFreezeTimeoutsSuccessful_forTesting(); int getNumStepDownsCausedByHigherTerm_forTesting(); BSONObj getElectionMetricsBSON(); |