Keep semaphore slots held while blocked jobs are enqueued in concurrency test - #776
Open
wintan1418 wants to merge 1 commit into
Open
Keep semaphore slots held while blocked jobs are enqueued in concurrency test#776wintan1418 wants to merge 1 commit into
wintan1418 wants to merge 1 commit into
Conversation
…ncy test "run several jobs over the same record limiting concurrency" claims all three semaphore slots with jobs A, B and C, then enqueues D-H expecting all five to block. A and B only paused for 0.5 seconds, so on a slow CI runner they could finish while D-H were still being inserted, freeing a slot that let some of them run instead of blocking and failing the +5 BlockedExecution assertion. Give A and B enough pause to outlive the enqueue window, and bump C accordingly so it still saves last. Related to rails#602
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.
Related to #602
Problem
ConcurrencyControlsTest#test_run_several_jobs_over_the_same_record_limiting_concurrencyis one of the most frequent CI flakes at the moment — it failed standalone on recentmainruns (e.g. the run for 7f59932) and on unrelated PR runs, always on the same assertion:The test claims all three semaphore slots with jobs A, B and C, waits until the three are claimed, then enqueues D–H expecting all five to become
BlockedExecution. A and B only pause for 0.5s — and that clock starts as soon as they're claimed, before the wait even returns. On a slow runner, by the time the five D–Hperform_laterinserts complete, A or B has already finished and released a semaphore slot, so one of D–H claims it instead of blocking, and the+5assertion comes up short.Fix
Give A and B enough pause (1.5s) to still be holding their slots while D–H are being enqueued, and bump C (3s → 4s) so it keeps finishing well after everything else, preserving the test's final
["C"]assertion. The constraint is now also documented in the test comment.Adds ~1s to the test's runtime in exchange for tripling the margin on the race window.
Testing
Ran the test 6 consecutive times on MySQL plus the full
concurrency_controls_test.rbfile — all green.