diff options
author | Ben Caimano <ben.caimano@mongodb.com> | 2019-10-17 00:51:52 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-17 00:51:52 +0000 |
commit | 27ed83ca30107c8e39417ba1dfed5ec0dd8b859d (patch) | |
tree | 399e5b548782b6c84627389f94ddb61909e2746a /src/mongo/watchdog | |
parent | b37eb88c8ae801751711dd54f2506d3561989db7 (diff) | |
download | mongo-27ed83ca30107c8e39417ba1dfed5ec0dd8b859d.tar.gz |
SERVER-43987 Require predicates with OperationContext::waitForConditionOrInterrupt()
Diffstat (limited to 'src/mongo/watchdog')
-rw-r--r-- | src/mongo/watchdog/watchdog.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/mongo/watchdog/watchdog.cpp b/src/mongo/watchdog/watchdog.cpp index 360b98a0be9..accc1b3b06d 100644 --- a/src/mongo/watchdog/watchdog.cpp +++ b/src/mongo/watchdog/watchdog.cpp @@ -151,21 +151,22 @@ void WatchdogPeriodicThread::doLoop() { // Check if the period is different? // We are signalled on period changes at which point we may be done waiting or need to // wait longer. - while (startTime + _period > preciseClockSource->now() && - _state != State::kShutdownRequested) { - auto s = opCtx->waitForConditionOrInterruptNoAssertUntil( - _condvar, lock, startTime + _period); - - if (!s.isOK()) { - // The only bad status is when we are in shutdown - if (!opCtx->getServiceContext()->getKillAllOperations()) { - severe() << "Watchdog was interrupted, shutting down, reason: " - << s.getStatus(); - exitCleanly(ExitCode::EXIT_ABRUPT); - } - - return; + try { + opCtx->waitForConditionOrInterruptUntil(_condvar, lock, startTime + _period, [&] { + return (startTime + _period) <= preciseClockSource->now() || + _state == State::kShutdownRequested; + }); + } catch (const DBException& e) { + // The only bad status is when we are in shutdown + if (!opCtx->getServiceContext()->getKillAllOperations()) { + severe() << "Watchdog was interrupted, shutting down, reason: " << e.toStatus(); + exitCleanly(ExitCode::EXIT_ABRUPT); } + + // This interruption ends the WatchdogPeriodicThread. This means it is possible to + // killOp this operation and stop it for the lifetime of the process. + LOG(1) << "WatchdogPeriodicThread interrupted by: " << e; + return; } // Are we done running? |