diff options
author | Sulabh Mahajan <sulabh.mahajan@mongodb.com> | 2019-02-26 09:36:43 +1100 |
---|---|---|
committer | Sulabh Mahajan <sulabh.mahajan@mongodb.com> | 2019-02-26 09:36:43 +1100 |
commit | bacb6b67706a2c057fcd0f76a38f416b225aa69a (patch) | |
tree | 83fa9cc540025c7b122822cf6c746699eab5642f /src/mongo/db/curop.cpp | |
parent | dbf6e7832948aef18a2bde086f6e8de20d65b2f1 (diff) | |
download | mongo-bacb6b67706a2c057fcd0f76a38f416b225aa69a.tar.gz |
SERVER-39361 Synchronise collecting storage engine stats with shutdown
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r-- | src/mongo/db/curop.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 8831d46ac95..5d5c1dd1240 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -43,6 +43,7 @@ #include "mongo/db/client.h" #include "mongo/db/commands.h" #include "mongo/db/commands/server_status_metric.h" +#include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/locker.h" #include "mongo/db/json.h" #include "mongo/db/query/getmore_request.h" @@ -404,7 +405,18 @@ bool CurOp::completeAndLogOperation(OperationContext* opCtx, if (shouldLogOp || (shouldSample && _debug.executionTimeMicros > slowMs * 1000LL)) { auto lockerInfo = opCtx->lockState()->getLockerInfo(_lockStatsBase); - _debug.storageStats = opCtx->recoveryUnit()->getOperationStatistics(); + if (opCtx->getServiceContext()->getStorageEngine()) { + // Take a lock before calling into the storage engine to prevent racing against + // a shutdown. We can get here and our lock acquisition be interrupted, log a + // message if that happens. + try { + Lock::GlobalLock lk(opCtx, MODE_IS); + _debug.storageStats = opCtx->recoveryUnit()->getOperationStatistics(); + } catch (const ExceptionForCat<ErrorCategory::Interruption>&) { + warning() + << "Interrupted while trying to gather storage statistics for a slow operation"; + } + } log(component) << _debug.report(client, *this, (lockerInfo ? &lockerInfo->stats : nullptr)); } |