Skip to content

fix(subscriptions): stop a checkpoint racing a delete from bringing the deleted subscription back - #69

Merged
yordis merged 2 commits into
yordis/refactor-drop-unused-lock-leasefrom
yordis/fix-ack-delete-race
Oct 26, 2026
Merged

yordis merged 2 commits into
yordis/refactor-drop-unused-lock-leasefrom
yordis/fix-ack-delete-race

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 subscription checkpoint error classification and concurrency behavior on the critical ack path; mistakes could mis-stop subscriptions or miss fencing.

Overview
Fixes incorrect :fenced results when a subscription checkpoint races a committed delete.

subscription_ack is now a plain UPDATE (no CTE returning acknowledged/present). When the update touches 0 rows, Ack.rejected runs a separate query_subscription_exists so existence is checked after the update finishes—avoiding the case where a delete commits while the ack waits on the row lock but an in-statement probe still sees the deleted row.

Outcomes: :subscription_not_found if the row is gone, :fenced if it still exists with a mismatched lock generation. A persistence test covers the ack-vs-delete lock race; the FSM test expects no :fenced when that follow-up probe cannot run, so the subscription is not told to reclaim the lock on a possibly deleted row.

Reviewed by Cursor Bugbot for commit f0ba616. 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 59 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: c69798ea-12ed-4377-9b55-58831a189e9c
Commits

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

Files selected for processing: 6
  • lib/event_store/sql/statements.ex
  • lib/event_store/sql/statements/query_subscription_exists.sql.eex
  • lib/event_store/sql/statements/subscription_ack.sql.eex
  • lib/event_store/storage/subscription.ex
  • test/storage/subscription_persistence_test.exs
  • test/subscriptions/subscription_fsm_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 ack delete race fix(subscriptions): stop a checkpoint racing a delete from bringing the deleted subscription back Oct 26, 2026
@yordis
yordis force-pushed the yordis/fix-ack-delete-race branch from f0ba616 to 5f44b3c 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-ack-delete-race branch from 5f44b3c to 4e5ceb2 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-ack-delete-race branch 2 times, most recently from 6879b1e to b1a7cf4 Compare October 26, 2026 17:47
…gone row for a fenced one

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…he deleted subscription back

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis force-pushed the yordis/fix-ack-delete-race branch from b1a7cf4 to 0715b61 Compare October 26, 2026 19:31
@yordis
yordis merged commit 65993e2 into main Oct 26, 2026
7 checks passed
@yordis
yordis deleted the yordis/fix-ack-delete-race 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