diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-12-30 17:01:13 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-12-30 17:09:28 -0500 |
commit | e49a2a16fb4b337d7ed1b0ec8d766f281741d8bf (patch) | |
tree | 7f0cac8cb50e56819bfe2546a525076976b1e193 /src/mongo/db/service_context_d.cpp | |
parent | 715e9e1cdc618dad480a7a1a73458daf6ea9ce0f (diff) | |
download | mongo-e49a2a16fb4b337d7ed1b0ec8d766f281741d8bf.tar.gz |
SERVER-22027 Sharding should not retry killed operations
This change introduces a different interruption code (11602) which will be
used to kill operations during replication primary stepdown so the config
server retry logic can differentiate them from user-killed operations.
Diffstat (limited to 'src/mongo/db/service_context_d.cpp')
-rw-r--r-- | src/mongo/db/service_context_d.cpp | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp index 3e5fd2d5be7..470dcb927a5 100644 --- a/src/mongo/db/service_context_d.cpp +++ b/src/mongo/db/service_context_d.cpp @@ -220,21 +220,9 @@ bool ServiceContextMongoD::getKillAllOperations() { return _globalKill; } -bool ServiceContextMongoD::_killOperationsAssociatedWithClientAndOpId_inlock(Client* client, - unsigned int opId) { - OperationContext* opCtx = client->getOperationContext(); - if (!opCtx) { - return false; - } - if (opCtx->getOpID() != opId) { - return false; - } - _killOperation_inlock(opCtx); - return true; -} - -void ServiceContextMongoD::_killOperation_inlock(OperationContext* opCtx) { - opCtx->markKilled(); +void ServiceContextMongoD::_killOperation_inlock(OperationContext* opCtx, + ErrorCodes::Error killCode) { + opCtx->markKilled(killCode); for (const auto listener : _killOpListeners) { try { @@ -248,8 +236,10 @@ void ServiceContextMongoD::_killOperation_inlock(OperationContext* opCtx) { bool ServiceContextMongoD::killOperation(unsigned int opId) { for (LockedClientsCursor cursor(this); Client* client = cursor.next();) { stdx::lock_guard<Client> lk(*client); - bool found = _killOperationsAssociatedWithClientAndOpId_inlock(client, opId); - if (found) { + + OperationContext* opCtx = client->getOperationContext(); + if (opCtx && opCtx->getOpID() == opId) { + _killOperation_inlock(opCtx, ErrorCodes::Interrupted); return true; } } @@ -257,7 +247,8 @@ bool ServiceContextMongoD::killOperation(unsigned int opId) { return false; } -void ServiceContextMongoD::killAllUserOperations(const OperationContext* txn) { +void ServiceContextMongoD::killAllUserOperations(const OperationContext* txn, + ErrorCodes::Error killCode) { for (LockedClientsCursor cursor(this); Client* client = cursor.next();) { if (!client->isFromUserConnection()) { // Don't kill system operations. @@ -266,16 +257,11 @@ void ServiceContextMongoD::killAllUserOperations(const OperationContext* txn) { stdx::lock_guard<Client> lk(*client); OperationContext* toKill = client->getOperationContext(); - if (!toKill) { - continue; - } - if (toKill->getOpID() == txn->getOpID()) { - // Don't kill ourself. - continue; + // Don't kill ourself. + if (toKill && toKill->getOpID() != txn->getOpID()) { + _killOperation_inlock(toKill, killCode); } - - _killOperation_inlock(toKill); } } |