[SERVER-53477] ThreadPool::waitForIdle should be interruptible on thread pool shutdown() Created: 22/Dec/20 Updated: 29/Oct/23 Resolved: 15/Mar/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 4.9.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Lingzhi Deng | Assignee: | George Wangensteen |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | servicearch-wfbf-day | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Operating System: | ALL | ||||||||||||
| Sprint: | Service Arch 2021-02-22, Service Arch 2021-03-08, Service Arch 2021-03-22 | ||||||||||||
| Participants: | |||||||||||||
| Linked BF Score: | 131 | ||||||||||||
| Story Points: | 2 | ||||||||||||
| Description |
|
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. |
| Comments |
| Comment by Githook User [ 11/Mar/21 ] |
|
Author: {'name': 'George Wangensteen', 'email': 'george.wangensteen@mongodb.com', 'username': 'gewa24'}Message: |