Skip to content

Commit 81d5975

Browse files
committed
Keep semaphore slots held while blocked jobs are enqueued in concurrency 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 #602
1 parent 7f59932 commit 81d5975

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

test/integration/concurrency_controls_test.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase
7575
# and B finish quickly, freeing slots that drain D–H; C reads the empty
7676
# status and pauses far longer than everyone else, so it saves last and its
7777
# write (built on the empty status) overwrites all the others, leaving "C".
78+
# A and B must pause long enough to still hold their semaphore slots while
79+
# D–H are being enqueued, even on a slow CI runner — otherwise some of D–H
80+
# claim a freed slot instead of blocking.
7881
assert_no_difference -> { SolidQueue::BlockedExecution.count } do
79-
ThrottledUpdateResultJob.perform_later(@result, name: "A", pause: 0.5.seconds)
80-
ThrottledUpdateResultJob.perform_later(@result, name: "B", pause: 0.5.seconds)
81-
ThrottledUpdateResultJob.perform_later(@result, name: "C", pause: 3.seconds)
82+
ThrottledUpdateResultJob.perform_later(@result, name: "A", pause: 1.5.seconds)
83+
ThrottledUpdateResultJob.perform_later(@result, name: "B", pause: 1.5.seconds)
84+
ThrottledUpdateResultJob.perform_later(@result, name: "C", pause: 4.seconds)
8285
end
8386

8487
wait_for(timeout: 2.seconds) { SolidQueue::ClaimedExecution.count >= 3 }

0 commit comments

Comments
 (0)