summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2020-03-06 15:33:37 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-09 13:35:51 +0000
commit8a9d5677f500293448311e6c551549b60cbfc780 (patch)
tree24abe32ca873be2453c4ac4d2c7cab38b27537ce
parent340c085a7fd3e589442bce69db86d51cae1e82a6 (diff)
downloadmongo-8a9d5677f500293448311e6c551549b60cbfc780.tar.gz
SERVER-46227 MozJSImplScope::kill() check for "correct thread" will always fail
-rw-r--r--jstests/concurrency/fsm_workloads/server_status_with_time_out_cursors.js9
-rw-r--r--src/mongo/scripting/mozjs/implscope.cpp3
-rw-r--r--src/mongo/scripting/mozjs/implscope.h6
3 files changed, 7 insertions, 11 deletions
diff --git a/jstests/concurrency/fsm_workloads/server_status_with_time_out_cursors.js b/jstests/concurrency/fsm_workloads/server_status_with_time_out_cursors.js
index cfa1876def0..39452ab2217 100644
--- a/jstests/concurrency/fsm_workloads/server_status_with_time_out_cursors.js
+++ b/jstests/concurrency/fsm_workloads/server_status_with_time_out_cursors.js
@@ -35,13 +35,8 @@ var $config = (function() {
const c = curs.itcount();
} catch (e) {
- // TODO SERVER-46227: Remove "ErrorCodes.Interrupted" once we are correctly checking
- // the OperationContext for kill reason in MozJSImplScope::kill().
- assert.commandFailedWithCode(e, [
- ErrorCodes.MaxTimeMSExpired,
- ErrorCodes.NetworkInterfaceExceededTimeLimit,
- ErrorCodes.Interrupted
- ]);
+ assert.commandFailedWithCode(
+ e, [ErrorCodes.MaxTimeMSExpired, ErrorCodes.NetworkInterfaceExceededTimeLimit]);
}
},
diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp
index 34729b87a33..f06a20bfc0a 100644
--- a/src/mongo/scripting/mozjs/implscope.cpp
+++ b/src/mongo/scripting/mozjs/implscope.cpp
@@ -136,6 +136,7 @@ void MozJSImplScope::registerOperation(OperationContext* opCtx) {
_opCtx = opCtx;
_opId = opCtx->getOpID();
+ _opCtxThreadId = stdx::this_thread::get_id();
_engine->registerOperation(opCtx, this);
}
@@ -153,7 +154,7 @@ void MozJSImplScope::kill() {
// If we are on the right thread, in the middle of an operation, and we have a registered
// opCtx, then we should check the opCtx for interrupts.
- if (_mr._thread.get_id() == stdx::this_thread::get_id() && _inOp > 0 && _opCtx) {
+ if (_opCtxThreadId == stdx::this_thread::get_id() && _inOp > 0 && _opCtx) {
_killStatus = _opCtx->checkForInterruptNoAssert();
}
diff --git a/src/mongo/scripting/mozjs/implscope.h b/src/mongo/scripting/mozjs/implscope.h
index c774efd3bd3..b842ae3cbef 100644
--- a/src/mongo/scripting/mozjs/implscope.h
+++ b/src/mongo/scripting/mozjs/implscope.h
@@ -379,7 +379,6 @@ private:
public:
MozRuntime(const MozJSScriptEngine* engine, boost::optional<int> jsHeapLimitMB);
- std::thread _thread; // NOLINT
std::unique_ptr<JSRuntime, std::function<void(JSRuntime*)>> _runtime;
std::unique_ptr<JSContext, std::function<void(JSContext*)>> _context;
};
@@ -417,8 +416,9 @@ private:
mutable Mutex _mutex = MONGO_MAKE_LATCH("MozJSImplScope::_mutex");
stdx::condition_variable _sleepCondition;
std::string _error;
- unsigned int _opId; // op id for this scope
- OperationContext* _opCtx; // Op context for DbEval
+ unsigned int _opId; // op id for this scope
+ OperationContext* _opCtx; // Op context for DbEval
+ stdx::thread::id _opCtxThreadId; // Id of the thread that owns '_opCtx'
std::size_t _inOp;
std::atomic<bool> _pendingGC; // NOLINT
ConnectState _connectState;