[SERVER-59516] Create opCtx outside of lock in oplog fetcher Created: 23/Aug/21  Updated: 29/Oct/23  Resolved: 24/Aug/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.3, 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Xuerui Fa Assignee: Xuerui Fa
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Participants:
Linked BF Score: 156

 Description   

In the OplogFetcher, we should create the opCtx before we obtain the lock here.

Since destructors are called in reverse order, the current code tries to destruct the opCtx when it goes out of scope before releasing the lock. This leads to a potential deadlock situation with tenant migrations.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 27/Aug/21 ]

Author:

{'name': 'XueruiFa', 'email': 'xuerui.fa@mongodb.com', 'username': 'XueruiFa'}

Message: SERVER-59516: Create opCtx outside of lock in oplog fetcher

(cherry picked from commit 8c345c6693b6b60947f5134cb76efdf4500258dd)
Branch: v5.0
https://github.com/mongodb/mongo/commit/3b0aa61b3e9737ba37a69e3e156722e3ea088e12

Comment by Daniel Gottlieb (Inactive) [ 25/Aug/21 ]

the current code tries to destruct the opCtx when it goes out of scope before releasing the lock. This leads to a potential deadlock situation with tenant migrations.

xuerui.fa Can you expand some on this? I imagine this means that destructing an OperationContext can acquire* resources? If that's so, can you point me to the code that does that?

Comment by Githook User [ 24/Aug/21 ]

Author:

{'name': 'XueruiFa', 'email': 'xuerui.fa@mongodb.com', 'username': 'XueruiFa'}

Message: SERVER-59516: Create opCtx outside of lock in oplog fetcher
Branch: master
https://github.com/mongodb/mongo/commit/8c345c6693b6b60947f5134cb76efdf4500258dd

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