[SERVER-46227] MozJSImplScope::kill() check for "correct thread" will always fail Created: 18/Feb/20  Updated: 29/Oct/23  Resolved: 09/Mar/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Bug Priority: Major - P3
Reporter: James Wahlin Assignee: James Wahlin
Resolution: Fixed Votes: 0
Labels: greenerbuild, qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
Related
related to SERVER-46225 Add Interrupted to timeout codes acce... Closed
is related to SERVER-42736 Fix memory leak in PosixNSPR.cpp when... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 42

 Description   

This can cause a MaxTimeMS timeout that involves $where or a JavaScript function to return "Interrupted" rather than "MaxTimeMSExpired", causing our server_status_with_time_out_cursors.js concurrency test to fail sporadically.

A quick fix for server_status_with_time_out_cursors.js is being made under SERVER-46225, which will add "Interrupted" to the accepted error list. This ticket will be used to fix the root cause and remove the quick fix.

This is caused by the "_mr._thread.get_id() == stdx::this_thread::get_id()" comparison on the following conditional:

        if (_mr._thread.get_id() == stdx::this_thread::get_id() && _inOp > 0 && _opCtx) {
            _killStatus = _opCtx->checkForInterruptNoAssert();
        }

"_mr._thread" is never initialized, so the "id" it holds will never be equal to that of the current thread. Failing this check means we will not check the OperationContext for kill reason and substitute with a more generic "Interrupted" error code.

The failing check is here: https://github.com/mongodb/mongo/blob/3f529eeb89a3821604012ea86e9ef7d6fb962a24/src/mongo/scripting/mozjs/implscope.cpp#L155-L159



 Comments   
Comment by Githook User [ 09/Mar/20 ]

Author:

{'username': 'jameswahlin', 'name': 'James Wahlin', 'email': 'james@mongodb.com'}

Message: SERVER-46227 MozJSImplScope::kill() check for "correct thread" will always fail
Branch: master
https://github.com/mongodb/mongo/commit/8a9d5677f500293448311e6c551549b60cbfc780

Generated at Thu Feb 08 05:10:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.