[SERVER-46613] Only register/deregister opCtx with the Scope during reattach/detach Created: 04/Mar/20  Updated: 27/Oct/23  Resolved: 19/Mar/20

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

Type: Task Priority: Major - P3
Reporter: James Wahlin Assignee: David Percy
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sprint: Query 2020-03-23
Participants:

 Description   

Currently, every time we call a JS function on a Scope, the Scope reregisters itself on the OperationContext, and then deregisters itself before returning. In a typical query this might happen many times on the same OperationContext. It seems like it would be simpler to only register/deregister once.

We have a similar mechanism already, called reattachToOperationContext() / detachFromOperationContext(), so let's try using that hook to register and deregister the Scope as well.



 Comments   
Comment by David Percy [ 19/Mar/20 ]

The original motivation for this ticket was to call register/unregister once per opCtx, rather than once per callFunction. We ended up fixing this as part of SERVER-46494: we register/unregister in the constructor/destructor of JsExecution, because JsExecution does not outlive the opCtx. In the future if we try to give JsExecution or Scope a longer lifetime, we'll probably need to come back to this and use the attach/detach mechanism.

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