Skip to content

Unblock waiting jobs when discarding ready jobs in bulk - #818

Merged
rosa merged 2 commits into
rails:mainfrom
ydah:fix-bulk-discard-unblocking
Nov 3, 2026
Merged

rosa merged 2 commits into
rails:mainfrom
ydah:fix-bulk-discard-unblocking

Conversation

@ydah

@ydah ydah commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Bulk discarding ready jobs, including through Queue#clear, releases semaphores without promoting blocked jobs. Successors remain blocked until expiration and concurrency maintenance.

Use the same unblock_next_blocked_job path as individual discards for each selected job. Bound batched discards by the initial maximum execution ID so newly promoted jobs survive subsequent batches.

ydah and others added 2 commits November 2, 2026 20:01
Bulk discards now free each job's concurrency slot and promote the next
blocked job one job at a time, so this lives next to the single-job
unblock_next_blocked_job as Job.unblock_next_blocked_jobs.

Semaphore.signal_all had no callers left. It also returned only one slot
when several discarded jobs shared a key, and never extended expires_at
like signal does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rosa
rosa force-pushed the fix-bulk-discard-unblocking branch from 436fe16 to 541c00d Compare November 3, 2026 07:41
@rosa

rosa commented Nov 3, 2026

Copy link
Copy Markdown
Member

Thanks a lot, @ydah! I rebased this onto main and added one commit on top: the per-job unblocking now lives in Job.unblock_next_blocked_jobs, next to unblock_next_blocked_job, and Semaphore.signal_all is gone since nothing calls it anymore. It also gave back only one slot when several discarded jobs shared a key, so your change fixes that too.

@rosa
rosa merged commit 27b8047 into rails:main Nov 3, 2026
170 of 174 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants