summaryrefslogtreecommitdiff
path: root/src/mongo/db/curop.cpp
diff options
context:
space:
mode:
authorSulabh Mahajan <sulabh.mahajan@mongodb.com>2019-02-26 09:36:43 +1100
committerSulabh Mahajan <sulabh.mahajan@mongodb.com>2019-02-26 09:36:43 +1100
commitbacb6b67706a2c057fcd0f76a38f416b225aa69a (patch)
tree83fa9cc540025c7b122822cf6c746699eab5642f /src/mongo/db/curop.cpp
parentdbf6e7832948aef18a2bde086f6e8de20d65b2f1 (diff)
downloadmongo-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.cpp14
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));
}