-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
-
ALL
-
Service Arch 2021-02-22, Service Arch 2021-03-08, Service Arch 2021-03-22
-
131
-
2
The header file claims that it is legal to call waitForIdle before shutdown is called. But it is not. On shutdown, the thread pool will drain all pending tasks and shut down all threads, after which the _numIdleThreads will become 0. So if we call shutdown, then waitForIdle would hang because _numIdleThreads (0) would be < the size of _thread (until join is called where we finally clear the _threads).
To fix this, we can make waitForIdle return on shutdown. As the comment in the thread pool header file says, if it is called before shutdown() is called, there is no guarantee that there will still be no pending tasks when the function returns. Or we should fix the comment.
Acceptance criteria:
Write unit test to verify reported behavior. If a hang is observed then figure out if we want to notify the condition variable/fix the hang.
- related to
-
SERVER-53410 No need to shutdown writerPool when interrupting recipient service instances
- Closed
-
SERVER-87115 ThreadPool::waitForIdle() may hang occasionally and return prematurely before draining pending tasks.
- Closed