Skip to content

Commit e2ee067

Browse files
committed
SERVER-12607 make [update/delete] write commands interruptable with killOp
1 parent cd1cdfc commit e2ee067

File tree

7 files changed

+35
-19
lines changed

7 files changed

+35
-19
lines changed

src/mongo/base/error_codes.err

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ error_code("NoClientContext", 81)
8484
error_code("NoProgressMade", 82)
8585

8686
# Non-sequential error codes (for compatibility only)
87-
error_code("DuplicateKey", 11000)
8887
error_code("NotMaster", 10107) #this comes from assert_util.h
88+
error_code("DuplicateKey", 11000)
89+
error_code("InterruptedAtShutdown", 11600)
8990
error_code("Interrupted", 11601)
9091
error_code("OutOfDiskSpace", 14031 )
9192

9293
error_class("NetworkError", ["HostUnreachable", "HostNotFound"])
94+
error_class("Interruption", ["Interrupted", "InterruptedAtShutdown", "ExceededTimeLimit"])

src/mongo/db/catalog/index_catalog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ namespace mongo {
338338
<< " error: " << exc;
339339

340340
if ( shutdownBehavior == SHUTDOWN_LEAVE_DIRTY &&
341-
exc.getCode() == InterruptedAtShutdown ) {
341+
exc.getCode() == ErrorCodes::InterruptedAtShutdown ) {
342342
indexBuildBlock.abort();
343343
}
344344
else {

src/mongo/db/catalog/index_create.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "mongo/db/catalog/index_create.h"
3232

33+
#include "mongo/base/error_codes.h"
3334
#include "mongo/client/dbclientinterface.h"
3435
#include "mongo/db/audit.h"
3536
#include "mongo/db/background.h"
@@ -128,7 +129,7 @@ namespace mongo {
128129
}
129130
}
130131
catch( AssertionException& e ) {
131-
if( e.interrupted() ) {
132+
if (ErrorCodes::isInterruption(DBException::convertExceptionCode(e.getCode()))) {
132133
killCurrentOp.checkForInterrupt();
133134
}
134135

src/mongo/db/commands/write_commands/batch_executor.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,6 @@ namespace mongo {
654654
if ( request.getOrdered() )
655655
break;
656656
}
657-
killCurrentOp.checkForInterrupt();
658657
}
659658
}
660659
else {
@@ -669,7 +668,6 @@ namespace mongo {
669668
if ( request.getOrdered() )
670669
break;
671670
}
672-
killCurrentOp.checkForInterrupt();
673671
}
674672
}
675673

@@ -772,7 +770,11 @@ namespace mongo {
772770
}
773771
}
774772
catch ( const DBException& ex ) {
775-
currResult.error = toWriteError( ex.toStatus() );
773+
Status stat(ex.toStatus());
774+
if (ErrorCodes::isInterruption(stat.code())) {
775+
throw;
776+
}
777+
currResult.error = toWriteError(stat);
776778
}
777779

778780
//
@@ -999,7 +1001,11 @@ namespace mongo {
9991001
result->fault = new PageFaultException( ex );
10001002
}
10011003
catch ( const DBException& ex ) {
1002-
result->error = toWriteError( ex.toStatus() );
1004+
Status stat(ex.toStatus());
1005+
if (ErrorCodes::isInterruption(stat.code())) {
1006+
throw;
1007+
}
1008+
result->error = toWriteError(stat);
10031009
}
10041010

10051011
}
@@ -1039,7 +1045,11 @@ namespace mongo {
10391045
result->fault = new PageFaultException( ex );
10401046
}
10411047
catch ( const DBException& ex ) {
1042-
result->error = toWriteError( ex.toStatus() );
1048+
Status stat(ex.toStatus());
1049+
if (ErrorCodes::isInterruption(stat.code())) {
1050+
throw;
1051+
}
1052+
result->error = toWriteError(stat);
10431053
}
10441054
}
10451055

@@ -1089,7 +1099,11 @@ namespace mongo {
10891099
result->stats.upsertedID = resUpsertedID;
10901100
}
10911101
catch (const DBException& ex) {
1092-
result->error = toWriteError(ex.toStatus());
1102+
Status stat(ex.toStatus());
1103+
if (ErrorCodes::isInterruption(stat.code())) {
1104+
throw;
1105+
}
1106+
result->error = toWriteError(stat);
10931107
}
10941108
}
10951109

@@ -1119,7 +1133,11 @@ namespace mongo {
11191133
result->fault = new PageFaultException( ex );
11201134
}
11211135
catch ( const DBException& ex ) {
1122-
result->error = toWriteError( ex.toStatus() );
1136+
Status stat(ex.toStatus());
1137+
if (ErrorCodes::isInterruption(stat.code())) {
1138+
throw;
1139+
}
1140+
result->error = toWriteError(stat);
11231141
}
11241142
}
11251143

src/mongo/db/index/btree_based_access_method.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <vector>
3232

33+
#include "mongo/base/error_codes.h"
3334
#include "mongo/base/status.h"
3435
#include "mongo/db/curop.h"
3536
#include "mongo/db/extsort.h"
@@ -419,7 +420,8 @@ namespace mongo {
419420
throw;
420421
}
421422

422-
if( e.interrupted() ) {
423+
if (ErrorCodes::isInterruption(
424+
DBException::convertExceptionCode(e.getCode()))) {
423425
killCurrentOp.checkForInterrupt();
424426
}
425427

src/mongo/db/kill_current_op.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ namespace {
170170
return;
171171
}
172172

173-
uassert(InterruptedAtShutdown, "interrupted at shutdown", !_globalKill);
173+
uassert(ErrorCodes::InterruptedAtShutdown, "interrupted at shutdown", !_globalKill);
174174

175175
if (c.curop()->maxTimeHasExpired()) {
176176
c.curop()->kill();

src/mongo/util/assert_util.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ namespace mongo {
3131
enum CommonErrorCodes {
3232
OkCode = 0,
3333
DatabaseDifferCaseCode = 13297 , // uassert( 13297 )
34-
InterruptedAtShutdown = 11600 , // uassert( 11600 )
3534
SendStaleConfigCode = 13388 , // uassert( 13388 )
3635
RecvStaleConfigCode = 9996, // uassert( 9996 )
3736
PrepareConfigsFailedCode = 13104, // uassert( 13104 )
@@ -144,12 +143,6 @@ namespace mongo {
144143

145144
virtual bool severe() const { return true; }
146145
virtual bool isUserAssertion() const { return false; }
147-
148-
/* true if an interrupted exception - see KillCurrentOp */
149-
bool interrupted() {
150-
return _ei.code == InterruptedAtShutdown || _ei.code == 11601 ||
151-
_ei.code == ErrorCodes::ExceededTimeLimit;
152-
}
153146
};
154147

155148
/* UserExceptions are valid errors that a user can cause, like out of disk space or duplicate key */

0 commit comments

Comments
 (0)