[SERVER-54671] Ensure TopologyVersionObserver is always interrupted at shutdown Created: 19/Feb/21  Updated: 29/Oct/23  Resolved: 03/May/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Luis Osta (Inactive)
Resolution: Fixed Votes: 0
Labels: save-for-luis, servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service Arch 2021-05-17
Participants:
Linked BF Score: 22

 Description   

The shutdown method for ToplogyVersionObserver must interrupt the _workerOpCtx to ensure that the observer thread always returns (see here). However, the observer thread may create a new opCtx after checking if a shutdown is in progress (see here), violating this contract and introducing hangs. A simple fix to address this issue is to check the shutdown flag when holding the mutex and before setting _workerOpCtx.

{
    // Set the _workerOpCtx to our newly formed opCtxHandle before we unlock.
    stdx::lock_guard lk(_mutex);
    if (_shouldShutdown.load()) break;
    _workerOpCtx = opCtxHandle.get();
}



 Comments   
Comment by Githook User [ 03/May/21 ]

Author:

{'name': 'Luis Osta', 'email': 'luis.osta@mongodb.com', 'username': 'LuisOsta'}

Message: SERVER-54671 Ensure TopologyVersionObserver is always interrupted at shutdown
Branch: master
https://github.com/mongodb/mongo/commit/8146418360d299d9398696bbb1eac8deeb436f3a

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