Skip to content

AIA-733: Cap the number of blocked executions per concurrency key#5

Merged
jonhinson merged 1 commit into
batch-rc-2-on-v1.4.0from
feature/concurrency_max_blocked
May 22, 2026
Merged

AIA-733: Cap the number of blocked executions per concurrency key#5
jonhinson merged 1 commit into
batch-rc-2-on-v1.4.0from
feature/concurrency_max_blocked

Conversation

@jonhinson
Copy link
Copy Markdown

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.

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.
@lucasmeira-wealthbox lucasmeira-wealthbox changed the title Cap the number of blocked executions per concurrency key AIA-733: Cap the number of blocked executions per concurrency key May 22, 2026
@lucasmeira-wealthbox
Copy link
Copy Markdown

@jonhinson jonhinson merged commit 85eefc6 into batch-rc-2-on-v1.4.0 May 22, 2026
127 of 130 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.

3 participants