summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/rollback_impl.cpp
diff options
context:
space:
mode:
authorXuerui Fa <xuerui.fa@mongodb.com>2019-10-16 18:05:39 +0000
committerevergreen <evergreen@mongodb.com>2019-10-16 18:05:39 +0000
commitb3b494a72f0e19d7556bee627da7ae9b79e26a03 (patch)
treefebde7da37919aba32e1ad092ba6bb540b55cf8b /src/mongo/db/repl/rollback_impl.cpp
parentfbdd5712f9ff6714f5ce9804eb4e9decb25dd88b (diff)
downloadmongo-b3b494a72f0e19d7556bee627da7ae9b79e26a03.tar.gz
SERVER-42825 Log and track metrics.repl.stateTransition counters after stopped killing user operation
Diffstat (limited to 'src/mongo/db/repl/rollback_impl.cpp')
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index f88a6cdd751..12a5bc38b03 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -267,13 +267,13 @@ bool RollbackImpl::_isInShutdown() const {
return _inShutdown;
}
-namespace {
-void killAllUserOperations(OperationContext* opCtx) {
+void RollbackImpl::_killAllUserOperations(OperationContext* opCtx) {
invariant(opCtx);
ServiceContext* serviceCtx = opCtx->getServiceContext();
invariant(serviceCtx);
int numOpsKilled = 0;
+ int numOpsRunning = 0;
for (ServiceContext::LockedClientsCursor cursor(serviceCtx); Client* client = cursor.next();) {
stdx::lock_guard<Client> lk(*client);
@@ -291,12 +291,17 @@ void killAllUserOperations(OperationContext* opCtx) {
if (toKill && !toKill->isKillPending()) {
serviceCtx->killOperation(lk, toKill, ErrorCodes::InterruptedDueToReplStateChange);
numOpsKilled++;
+ } else {
+ numOpsRunning++;
}
}
- log() << "Killed {} operation(s) while transitioning to ROLLBACK"_format(numOpsKilled);
+ // Update the metrics for tracking user operations during state transitions.
+ _replicationCoordinator->updateAndLogStateTransitionMetrics(
+ ReplicationCoordinator::OpsKillingStateTransitionEnum::kRollback,
+ numOpsKilled,
+ numOpsRunning);
}
-} // namespace
Status RollbackImpl::_transitionToRollback(OperationContext* opCtx) {
invariant(opCtx);
@@ -312,7 +317,7 @@ Status RollbackImpl::_transitionToRollback(OperationContext* opCtx) {
// Kill all user operations to ensure we can successfully acquire the RSTL. Since the node
// must be a secondary, this is only killing readers, whose connections will be closed
// shortly regardless.
- killAllUserOperations(opCtx);
+ _killAllUserOperations(opCtx);
rstlLock.waitForLockUntil(Date_t::max());