Fix race conditions around executor reuse #120
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Once an executor has finished execution it needs to do three things:
The previous flow of events was:
If something is waiting on the task result, it can receive the result and submit another instance of the same task between steps 1 and 2 or steps 2 and 3.
Both cause problems, if it's before 2 then the scheduler will wrongly assume one of its slots is still occupied. If it's before 3,
the scheduler knows the right number of slots, but still can't reuse the executor.
In fact, the sequence of events should be reversed:
At the time of writing the initial race condition is reproduced fairly reliably in our Github Actions build; the test case for doing so is also included in this PR.