[SERVER-80978] Fix potential deadlock between TTLMonitor::onStepUp and prepared transaction Created: 12/Sep/23  Updated: 24/Jan/24  Resolved: 09/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0, 7.0.6, 5.0.25, 6.0.14

Type: Bug Priority: Major - P3
Reporter: Dan Larkin-York Assignee: Daotang Yang
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Fix
Related
related to SERVER-81192 Introduce background maintenance task... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0, v6.0, v5.0
Sprint: Execution NAMR Team 2023-09-18, Execution Team 2023-12-11, Execution Team 2023-12-25, Execution Team 2024-01-08, Execution Team 2024-01-22
Participants:
Linked BF Score: 3

 Description   

The mechanism introduced in SERVER-68477 to resolve invalid expireAfterSeconds values and prevent unintended document deletions can potentially induce a deadlock during step-up with appropriate prepared transactions.

A prepared transaction which has a write to a collection "foo" will reacquire an IX lock on "foo" prior to running the index onStepUp method, where the TTLMonitor will attempt to acquire an X lock on a collection "foo" if it decides it needs to normalize its index spec. We cannot safely reverse the order of the operations.

As of this time we have not observed this deadlock in practice in any released builds, so we believe it to be extremely rare, and will be addressing it out of an abundance of caution.



 Comments   
Comment by Githook User [ 24/Jan/24 ]

Author:

{'name': 'mongodt', 'email': '146988481+mongodt@users.noreply.github.com', 'username': 'mongodt'}

Message: SERVER-80978 Fix potential deadlock between TTLMonitor::onStepUp and prepared transaction (#17863)

(cherry picked from commit 662c63e868af3fe388ad4d81b14c479b2f5be7f9)

GitOrigin-RevId: 4b5d21e1ada5db5ac9eb662707a98cc4df17ecad
Branch: v5.0
https://github.com/mongodb/mongo/commit/6328bdefc28e386f56e53d06723dd29ae6d5b24a

Comment by Githook User [ 18/Jan/24 ]

Author:

{'name': 'mongodt', 'email': '146988481+mongodt@users.noreply.github.com', 'username': 'mongodt'}

Message: SERVER-80978 Fix potential deadlock between TTLMonitor::onStepUp and prepared transaction (#17863)

(cherry picked from commit 662c63e868af3fe388ad4d81b14c479b2f5be7f9)

GitOrigin-RevId: 7a2d8a34790a82eafc406047efe0985fe0064e44
Branch: v6.0
https://github.com/mongodb/mongo/commit/8df7f440f9f135da0ae8b6b9e34a456bc68b3057

Comment by Githook User [ 17/Jan/24 ]

Author:

{'name': 'mongodt', 'email': '146988481+mongodt@users.noreply.github.com', 'username': 'mongodt'}

Message: SERVER-80978 Fix potential deadlock between TTLMonitor::onStepUp and prepared transaction (#17863)

(cherry picked from commit 662c63e868af3fe388ad4d81b14c479b2f5be7f9)

GitOrigin-RevId: 3f108e717fbe7d00caeb67993f695efbf3f95093
Branch: v7.0
https://github.com/mongodb/mongo/commit/462ae8ae2570308a697395365d7080d370e7c317

Comment by Githook User [ 09/Jan/24 ]

Author:

{'name': 'mongodt', 'email': '146988481+mongodt@users.noreply.github.com', 'username': 'mongodt'}

Message: SERVER-80978 Fix potential deadlock between TTLMonitor::onStepUp and prepared transaction (#17863)

GitOrigin-RevId: 662c63e868af3fe388ad4d81b14c479b2f5be7f9
Branch: master
https://github.com/mongodb/mongo/commit/6e9f1c857df45d4d17c1bef31801322dd40415e5

Generated at Thu Feb 08 06:45:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.