Conversation
This uses essentially a trinary return from `fetch_next_metajob` to determine if a race condition occured where the buffer was emptied between the check and the buffer shift. Co-Authored-By: Thomas van der Pol <tvdp@hey.com> Co-Authored-By: Brendan Weibrecht <brendan@weibrecht.net.au>
From a [comment](#285 (comment)) by @ebeigarts Co-Authored-By: Edgars Beigarts <edgars.beigarts@gmail.com>
… excess jobs above the buffer's max size
…hift deadlock test Restores the concurrency and and job count per thread to those from the originally submitted test. With the deadlock fix removed, it can now produce a deadlock most of the time (83% of runs in my testing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The changes in #285 unfortunately introduced a race condition bug where the result from
Worker#fetch_next_metajob(which just callsJobBuffer#shift) could be unexpectedly nil, and so the truthiness check in theWorker#work_loop's while loop could evaluate to false, causing the worker thread to stop. For details, see #285 (comment).We've fixed this by handling nil separately from false, and in that case, restarting the loop to do the fetch again, which should return a proper result the next time. We realise it's not the cleanest of fixes, but we'd prefer to get the fix in, and refactor later if the need arises.
The test this adds covers the changes from: here, #285, and #318. It's a fixed version of the test submitted in a comment by @ebeigarts: #285 (comment)