gh-66587: Fix deadlock from pool worker death without communication#16103
gh-66587: Fix deadlock from pool worker death without communication#16103applio wants to merge 6 commits into
Conversation
…ueue; adds test for issue22393/issue38084.
|
This looks good to me, simply a few remarks:
Also pinging @tomMoral |
Sorry, something went wrong.
|
For mine, I think this fix seems more elegant than #10441, but the tests in that PR seem to have more coverage. I personally prefer to just have the task fail, and the pool continue. The current behaviour is that the broken worker is immediately replaced and other work continues, but if you wait on the failed task then it will never complete. Now it does complete (with a failure), which means robust code can re-queue it if appropriate. I don't see any reason to tear down the entire pool. Few comments on the PR incoming. |
Sorry, something went wrong.
tomMoral
left a comment
There was a problem hiding this comment.
Here is a batch of comments.
I have to say that I like this solution as it is the most robust way of handling this, (a kind of scheduler). But it also comes with more complexity and increase communication needs -> more changes for deadlocks.
One of the main argument for the fail on error design is that there is no way there is no way to know in the main process if the worker that died had a lock on one of the communication queue. In this situation, the only way to recover the system and avoid a deadlock is to kill the Pool and re-spawn one.
Sorry, something went wrong.
Co-Authored-By: Steve Dower <steve.dower@microsoft.com>
taleinat
left a comment
There was a problem hiding this comment.
Additional tests would certainly be a good idea.
Sorry, something went wrong.
|
@applio, I'm not sure where this one is at, but I believe there are some comments that still need to be addressed. I don't know if it's waiting on anything else, but it would probably be nice to get this merged. |
Sorry, something went wrong.
|
Closing and re-opening to re-trigger CI. |
Sorry, something went wrong.
|
This missed the boat for inclusion in Python 3.9 which accepts security fixes only as of today. |
Sorry, something went wrong.
|
The following commit authors need to sign the Contributor License Agreement: |
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
Adds tracking of which worker process in the pool takes which job from the queue.
When a worker process dies without communication, its task/job is also lost. By tracking what job that worker took off the job queue as its task, upon detecting the death, the parent process can add an item to the result queue indicating the failure of that task/job.
In case of a future regression, the supplied test uses subprocess to constrain the test with a timeout to ensure an indefinite hang does not interfere with the running of tests.
https://bugs.python.org/issue22393