Skip to content

WI-4: Release per-stream subscription connections on unsubscribe (#683)#691

Draft
NickSeagull wants to merge 1 commit into
mainfrom
fix/683-per-stream-connection-release
Draft

WI-4: Release per-stream subscription connections on unsubscribe (#683)#691
NickSeagull wants to merge 1 commit into
mainfrom
fix/683-per-stream-connection-release

Conversation

@NickSeagull

Copy link
Copy Markdown
Member

ADR open for review

This draft PR opens docs/decisions/0063-per-stream-subscription-connection-release.md (Status: Proposed) for review.

ADR-0063 fixes the per-stream subscription connection leak (WI-4 of epic #679): subscribeToStreamEventsImpl acquires a dedicated unpooled Hasql.acquire connection per stream subscription, but unsubscribeImpl never releases it, so under stream-subscription churn connections accumulate against the Azure Flexible Server B1ms ~35-usable ceiling.

The proposed fix ties each per-stream connection's lifetime to its SubscriptionId: SubscriptionInfo carries an onRemove cleanup Task (a no-op for global/entity subscriptions), the stream subscribe path registers Hasql.release of its connection, and removeSubscription runs that cleanup best-effort (logged, never blocking unsubscribe). This mirrors the ADR-0039 close/cleanup lifecycle one level down. The ADR also documents a concurrency cap of ~14 concurrent stream subscriptions on B1ms, derived from ADR-0060's 19 + N ≤ 35 budget (handed to WI-6, #685, for the deploy guide).

What lands later

The implementation (SubscriptionStore + Internal.hs changes, plus happy-path / error / boundary / no-leak regression tests) lands in subsequent commits on this branch through the feature pipeline. This PR stays a draft until the pipeline's PR gate (phase 16), at which point it is marked Ready for review.

Closes #683

)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 63af0ffe-66d5-4429-8698-7c6e6fe2fb87

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/683-per-stream-connection-release

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

WI-4: Release per-stream subscription connections on unsubscribe

2 participants