[SERVER-64024] fix race in tearDown of ThreadedOperationDeadlineTests Created: 27/Feb/22  Updated: 29/Oct/23  Resolved: 01/Mar/22

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

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
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: Service Arch 2022-03-07
Participants:
Linked BF Score: 141

 Description   

These tests create a waiter thread that generates timer-based activity on an opCtx, including making its wait member functions throw exceptions.
The TSAN alerts in BF-24287 were generated by the destructor of the waiter thread.
The destructor wrote over some DBException Status fields that were read by the main thread. Without a synchronization point after the main thread reads Status.code, the waiter thread shutdown destroys the Status.

This should be a false alarm, because the exception thrown by the packaged_task's callback function should be attached to the std::future associated with the std::packaged_task, and after delivery to the std::future, the std::future should no longer share any state with the std::packaged_task. Destruction of the task should not affect the delivered exception's Status object.

This race can be eliminated by destroying the packaged_task on the main thread, and joining the waiter thread at the bottom of the test's scope. Adding it as a data member of the WaitTestState achieves this.



 Comments   
Comment by Githook User [ 01/Mar/22 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-64024 destroy the packaged_task on the thread it was created
Branch: master
https://github.com/mongodb/mongo/commit/8c85963c5e8e6cec0ba996de80e3cc7aa5a6b39d

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