diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-04-04 15:59:49 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-04-05 12:44:10 -0400 |
commit | 8765acc0fcc6ca3dd7158521ba8d864af4e0f2df (patch) | |
tree | 9fc35ffc0f93b334bbc846cb6ccf91250ae11252 /src/mongo/db/service_context.cpp | |
parent | 97691221bcf43245ddfd906766abc93bb617d2aa (diff) | |
download | mongo-8765acc0fcc6ca3dd7158521ba8d864af4e0f2df.tar.gz |
SERVER-27691 Make OperationContext::setKillAllOperations interrupt all operations
Diffstat (limited to 'src/mongo/db/service_context.cpp')
-rw-r--r-- | src/mongo/db/service_context.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp index 1509fca8367..de50199c149 100644 --- a/src/mongo/db/service_context.cpp +++ b/src/mongo/db/service_context.cpp @@ -293,7 +293,20 @@ void appendStorageEngineList(BSONObjBuilder* result) { void ServiceContext::setKillAllOperations() { stdx::lock_guard<stdx::mutex> clientLock(_mutex); + + // Ensure that all newly created operation contexts will immediately be in the interrupted state _globalKill.store(true); + + // Interrupt all active operations + for (auto&& client : _clients) { + stdx::lock_guard<Client> lk(*client); + auto opCtxToKill = client->getOperationContext(); + if (opCtxToKill) { + killOperation(opCtxToKill, ErrorCodes::InterruptedAtShutdown); + } + } + + // Notify any listeners who need to reach to the server shutting down for (const auto listener : _killOpListeners) { try { listener->interruptAll(); |