[SERVER-70256] Fix the race condition in ClusterCursorManager Created: 05/Oct/22  Updated: 29/Oct/23  Resolved: 13/Oct/22

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

Type: Bug Priority: Major - P3
Reporter: Mohammad Dashti (Inactive) Assignee: Romans Kasperovics
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to SERVER-70486 Reduce the number of mutex locks in C... Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2022-10-17
Participants:
Linked BF Score: 129

 Description   

It appears that cursorsTimedOut() and incrementCursorsTimedOut can be called on different threads, and there is no lock
https://github.com/10gen/mongo/blob/7b470a0d23c5a0e86f398082f88e1f136837d320/src/mongo/s/query/cluster_cursor_manager.h#L518-L524

Here's the writer:
https://github.com/10agen/mongo/blob/7b470a0d23c5a0e86f398082f88e1f136837d320/src/mongo/s/query/cluster_cursor_cleanup_job.cpp#L65-L66

 

Here's the reader:
https://github.com/10gen/mongo/blob/7b470a0d23c5a0e86f398082f88e1f136837d320/src/mongo/s/cluster_cursor_stats.cpp#L48-L49

In practice, this race is unlikely, but it's worth fixing. Also, it's creating a lot of noise on TSAN builds (e.g., BF-26555). Probably just using a std::atomic for _cursorsTimedOut will solve the issue.



 Comments   
Comment by Githook User [ 11/Oct/22 ]

Author:

{'name': 'Romans Kasperovics', 'email': 'romans.kasperovics@mongodb.com', 'username': 'romanskas'}

Message: SERVER-70256 Protect ClusterCursorManager::_cursorsTimeOut from data race
Branch: master
https://github.com/mongodb/mongo/commit/2e21f0a40bdce56be9d96059356f8c79a1dbc105

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