AIA-733: Cap the number of blocked executions per concurrency key#5
Merged
Merged
Conversation
Add a `max_blocked:` option to `limits_concurrency` that bounds how many jobs can sit in the blocked queue for a given concurrency key. Once the cap is reached, further conflicting jobs are silently discarded instead of joining an ever-growing blocked queue. The default is `nil`, preserving the existing unbounded behaviour. The option is only consulted on the `on_conflict: :block` path; with `:discard`, every conflict is destroyed regardless, so `max_blocked` is a no-op there. The cap is enforced under the existing per-key semaphore row lock, so concurrent enqueues racing to fill the last slot serialize against each other and the cap is never blown. When a finishing job releases the semaphore and promotes a blocked execution to ready, the slot reopens for the next enqueue — no dispatcher or release-path changes needed.
jpcamara
approved these changes
May 22, 2026
2 tasks
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.
Add a
max_blocked:option tolimits_concurrencythat bounds how many jobs can sit in the blocked queue for a given concurrency key. Once the cap is reached, further conflicting jobs are silently discarded instead of joining an ever-growing blocked queue.The default is
nil, preserving the existing unbounded behaviour. The option is only consulted on theon_conflict: :blockpath; with:discard, every conflict is destroyed regardless, somax_blockedis a no-op there.The cap is enforced under the existing per-key semaphore row lock, so concurrent enqueues racing to fill the last slot serialize against each other and the cap is never blown.
When a finishing job releases the semaphore and promotes a blocked execution to ready, the slot reopens for the next enqueue — no dispatcher or release-path changes needed.