Skip to content

fix(subscriptions): share the activation slots between tenants - #3418

Open
angela-helios wants to merge 1 commit into
mainfrom
fix/3111-fair-activation-slots
Open

angela-helios wants to merge 1 commit into
mainfrom
fix/3111-fair-activation-slots

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Closes #3111

Behaviour change to review

One tenant now runs at most half of HFS_SUBSCRIPTION_HANDSHAKE_CONCURRENCY activation flows at once, rounded up: 4 of the default 8. This also applies to a single-tenant deployment; an operator who wants the previous rate for one tenant doubles the setting. No new setting is added, and nothing is rejected: activations past the share wait.

Summary

The activation slots were shared by every tenant, and the next pending activation was picked in HashMap order. A tenant with many requested Subscriptions on endpoints that never answer could hold every slot and delay other tenants' activation without a bound.

  • Pending activations are served in turns by tenant, and in arrival order within a tenant. The pick no longer scans the whole activation map.
  • A tenant that runs its share of the slots is skipped and keeps its turn, so it leaves the remaining slots to the others. With a limit of 1 the share is the whole limit and only the turns apply.
  • DispatchSnapshot reports the share as handshake_concurrency_per_tenant.
  • The README describes the share and the order.

Not covered: the per-tenant share of channel attempt slots, a cap on pending activations, and the separate startup rehydration limit (HFS_SUBSCRIPTION_REHYDRATE_HANDSHAKE_CONCURRENCY), which still admits stored Subscriptions in tenant order.

Tests

New unit tests in engine/dispatch.rs:

  • pending_activations_take_turns_by_tenant_in_arrival_order
  • a_tenant_at_its_activation_share_is_skipped_and_keeps_its_turn
  • a_removed_pending_activation_leaves_the_order
  • one_tenant_cannot_hold_every_activation_slot: one tenant's endpoints never answer, and another tenant's Subscription still becomes active
  • a_deleted_subscription_returns_its_activation_share

Results:

  • cargo test -p helios-subscriptions --lib: 258 passed. --test dispatch_backpressure: 20 passed. --test rehydrate_integration: 15 passed. --test status_persistence: 8 passed.
  • cargo test -p helios-rest --lib with the subscriptions feature: 1149 passed.
  • I did not run clippy locally; CI runs it.

These ran together with the fix for #2723. Both edit crates/subscriptions/README.md and conflict there (text only), so the later one to merge needs its branch updated.

Pending activations were picked in HashMap order from one global set, so a
tenant with many Subscriptions on endpoints that never answer the handshake
could hold every activation slot. Pending activations now take turns by
tenant, in arrival order within a tenant, and one tenant runs at most half of
handshake_concurrency (rounded up). DispatchSnapshot reports the share.

Closes #3111
@claude

claude Bot commented Dec 2, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants