Skip to content

fix(subscriptions): stop events heard while disconnected from multiplying retries against the database - #70

Merged
yordis merged 2 commits into
yordis/fix-ack-delete-racefrom
yordis/fix-retry-timer-dedupe
Oct 26, 2026
Merged

yordis merged 2 commits into
yordis/fix-ack-delete-racefrom
yordis/fix-retry-timer-dedupe

Conversation

@yordis

@yordis yordis commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

@cursor

cursor Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes disconnected-subscription retry scheduling in a core GenServer path; behavior is narrower (fewer retries) with a targeted regression test, but affects reconnection under lock loss.

Overview
Fixes a reconnect storm where each {:events, ...} handled while the subscription FSM was :initial or :disconnected scheduled another Process.send_after(..., :subscribe_to_stream), multiplying DB subscribe attempts on busy streams.

The subscription GenServer now tracks a retry_timer reference and only arms the next retry when no timer is already pending; handling :subscribe_to_stream clears the timer before attempting subscribe again.

Adds a locking test that disconnects the subscription, floods it with ten synthetic event messages, and asserts only one :subscribe_to_stream retry is scheduled (via Erlang tracing of send_after).

Reviewed by Cursor Bugbot for commit d5116c4. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 37768ba9-311e-42eb-bccc-e9c3fcdab22b
Commits

Reviewing files that changed from the base of the PR and between 0715b61 and d5116c4.

Files selected for processing: 2
  • lib/event_store/subscriptions/subscription.ex
  • test/subscriptions/subscription_locking_test.exs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@yordis
yordis added this pull request to stack #73 October 26, 2026 16:00
@yordis yordis changed the title yordis/fix retry timer dedupe fix(subscriptions): stop events heard while disconnected from multiplying retries against the database Oct 26, 2026
@yordis
yordis force-pushed the yordis/fix-retry-timer-dedupe branch from b56757c to 0fd1c62 Compare October 26, 2026 16:16
@yordis
yordis removed this pull request from stack #73 October 26, 2026 16:53
@yordis
yordis force-pushed the yordis/fix-retry-timer-dedupe branch from 0fd1c62 to 29e9c89 Compare October 26, 2026 16:54
@yordis
yordis added this pull request to stack #74 October 26, 2026 17:10
@yordis
yordis force-pushed the yordis/fix-retry-timer-dedupe branch 3 times, most recently from 331e503 to a768599 Compare October 26, 2026 19:31
… up another retry

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…ying retries against the database

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis force-pushed the yordis/fix-retry-timer-dedupe branch from a768599 to d5116c4 Compare October 26, 2026 20:27
@yordis
yordis merged commit 383d9df into main Oct 26, 2026
7 checks passed
@yordis
yordis deleted the yordis/fix-retry-timer-dedupe branch October 26, 2026 22:05
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.

1 participant