Skip to content

Commit 93f767c

Browse files
committed
SERVER-22349 Throw interruptions from loadStored
The JS engine's loadStored eats exceptions that occur while it's loading functions from system.js. This also eats interruption exceptions, which can lead to a situation where a map reduce job is killed during loadStored, but the interrupt is lost. For tests where the map or reduce stages are long or non-terminating, and we rely on killing them, this can lead to hangs. Re-throwing interrupts from the try/catch block around loadStored fixes this behavior.
1 parent 38cd699 commit 93f767c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/mongo/scripting/engine.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ void Scope::loadStored(OperationContext* txn, bool ignoreNotConnected) {
231231
thisTime.insert(n.valuestr());
232232
_storedNames.insert(n.valuestr());
233233
} catch (const DBException& setElemEx) {
234+
if (setElemEx.getCode() == ErrorCodes::Interrupted) {
235+
throw;
236+
}
237+
234238
error() << "unable to load stored JavaScript function " << n.valuestr()
235239
<< "(): " << setElemEx.what() << endl;
236240
}

src/mongo/scripting/mozjs/implscope.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool MozJSImplScope::_interruptCallback(JSContext* cx) {
185185
if (scope->_hasOutOfMemoryException) {
186186
scope->_status = Status(ErrorCodes::JSInterpreterFailure, "Out of memory");
187187
} else if (scope->isKillPending()) {
188-
scope->_status = Status(ErrorCodes::JSInterpreterFailure, "Interrupted by the host");
188+
scope->_status = Status(ErrorCodes::Interrupted, "Interrupted by the host");
189189
}
190190

191191
if (!scope->_status.isOK()) {

0 commit comments

Comments
 (0)