Skip to content

fix(subscriptions): keep a long table lock on subscriptions from dropping every lock on the node - #59

Merged
yordis merged 2 commits into
yordis/fix-checkout-retries-per-callfrom
yordis/fix-claim-lock-wait
Oct 26, 2026
Merged

yordis merged 2 commits into
yordis/fix-checkout-retries-per-callfrom
yordis/fix-claim-lock-wait

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 lock acquisition timing and error paths in a concurrency-sensitive area; mis-tuned timeouts could cause more :lock_not_available failures under contention.

Overview
Subscription lock claims now cap how long Postgres waits on row/table locks so a blocked claim_subscription_lock does not run until the pool query timeout tears down the session and drops every advisory lock on that connection.

Storage.Lock.claim_subscription_lock wraps the claim in a short transaction that runs a new bound_lock_wait SQL statement (sets session lock_timeout when appropriate, using half of the caller’s :timeout or a 15s default; :infinity skips tightening). Lock-wait failures surface as Postgrex.Error with :lock_not_available instead of hanging until connection loss.

Tests add a scenario where an exclusive subscriptions table lock blocks a second claim: the waiter errors quickly, the first lease stays valid (no spurious lock_released), and the held subscription lock remains taken.

Reviewed by Cursor Bugbot for commit 081a4ae. 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 23 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: 0d1dac9e-0070-4375-ab17-80163b0e0631
Commits

Reviewing files that changed from the base of the PR and between db8ed35 and c114db1.

Files selected for processing: 4
  • lib/event_store/sql/statements.ex
  • lib/event_store/sql/statements/bound_lock_wait.sql.eex
  • lib/event_store/storage/lock.ex
  • test/advisory_locks_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 claim lock wait fix(subscriptions): keep a long table lock on subscriptions from dropping every lock on the node Oct 26, 2026
@yordis
yordis force-pushed the yordis/fix-claim-lock-wait branch from 081a4ae to 2ee389f 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-claim-lock-wait branch from 2ee389f to 4ee4271 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-claim-lock-wait branch from 4ee4271 to e01fddd Compare October 26, 2026 17:46
…ery lock on the node

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…ping every lock on the node

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis force-pushed the yordis/fix-claim-lock-wait branch from e01fddd to c114db1 Compare October 26, 2026 17:47
@yordis
yordis merged commit 6ed3bf2 into main Oct 26, 2026
7 checks passed
@yordis
yordis deleted the yordis/fix-claim-lock-wait branch October 26, 2026 19:31
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