-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code
-
Fully Compatible
-
ALL
-
Service Arch 2021-05-17
-
22
-
None
-
None
-
None
-
None
-
None
-
None
-
None
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();
}