[SERVER-39084] Race in wiredTigerPrepareConflictRetry Created: 18/Jan/19  Updated: 29/Oct/23  Resolved: 19/Feb/19

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

Type: Bug Priority: Major - P3
Reporter: Matthew Russotto Assignee: Xiangyu Yao (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Storage NYC 2019-02-11, Storage NYC 2019-02-25
Participants:
Linked BF Score: 17

 Description   

In wiredTigerPrepareConflictRetry, we make the attempt to do the read here

https://github.com/mongodb/mongo/blob/916a5553/src/mongo/db/storage/wiredtiger/wiredtiger_prepare_conflict.h#L66

We then wait by noting the value of the _lastCommitOrAbortCounter and waiting for it to change here:

https://github.com/mongodb/mongo/blob/916a5553/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp#L336

But we don't lock the mutex associated with _lastCommitOrAbortCounter until here

https://github.com/mongodb/mongo/blob/916a5553/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp#L334

So if _lastCommitOrAbortCounter updates after the prepare conflict but before we get the lock, we could wait indefinitely



 Comments   
Comment by Githook User [ 19/Feb/19 ]

Author:

{'name': 'Xiangyu Yao', 'username': 'xy24', 'email': 'xiangyu.yao@mongodb.com'}

Message: SERVER-39084 Fix race condition in PrepareConflictRetry
Branch: master
https://github.com/mongodb/mongo/commit/cd844d04fd5ca4a5f4224c4423491e37af700ccc

Generated at Thu Feb 08 04:50:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.