diff options
author | Benety Goh <benety@mongodb.com> | 2018-11-28 23:19:56 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2018-11-28 23:19:56 -0500 |
commit | 41c44d02cf39ef581888bed68c547e4ed9b5a323 (patch) | |
tree | eef10e598833c21ec66524cb9d52ed96043097d5 /src/mongo/db/index_builder.cpp | |
parent | 03e13f90426a82a97cbb0f926385e09904519259 (diff) | |
download | mongo-41c44d02cf39ef581888bed68c547e4ed9b5a323.tar.gz |
SERVER-37729 background index builds on secondaries cannot be interrupted by killOp
Diffstat (limited to 'src/mongo/db/index_builder.cpp')
-rw-r--r-- | src/mongo/db/index_builder.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index b6fc9895c82..c4977673c37 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -141,7 +141,15 @@ void IndexBuilder::run() { Lock::DBLock dlk(opCtx.get(), ns.db(), MODE_X); Database* db = DatabaseHolder::getDatabaseHolder().get(opCtx.get(), ns.db().toString()); - Status status = _build(opCtx.get(), db, true, &dlk); + // This background index build can only be interrupted at shutdown. + // For the duration of the OperationContext::runWithoutInterruption() invocation, any kill + // status set by the killOp command will be ignored. + // After OperationContext::runWithoutInterruption() returns, any call to + // OperationContext::checkForInterrupt() will see the kill status and respond accordingly + // (checkForInterrupt() will throw an exception while checkForInterruptNoAssert() returns + // an error Status). + Status status = + opCtx->runWithoutInterruption([&, this] { return _build(opCtx.get(), db, true, &dlk); }); if (!status.isOK()) { error() << "IndexBuilder could not build index: " << redact(status); fassert(28555, ErrorCodes::isInterruption(status.code())); |