Skip to content

feat: allow advisory_lock_name proc to receive instance for per-tenant lock granularity#491

Merged
seuros merged 1 commit intomasterfrom
feat/instance-aware-advisory-lock-name
May 6, 2026
Merged

feat: allow advisory_lock_name proc to receive instance for per-tenant lock granularity#491
seuros merged 1 commit intomasterfrom
feat/instance-aware-advisory-lock-name

Conversation

@seuros
Copy link
Copy Markdown
Member

@seuros seuros commented May 6, 2026

When advisory_lock_name is a 2-arity proc, it receives (base_class, instance) so callers can derive per-instance lock names (e.g. by tenant/scope column).

1-arity procs continue to receive only base_class.

Instance-method call sites pass self; class-method sites pass nil, falling back to the model-wide lock name as before.

Close #490
fixes #240

…t lock granularity

When advisory_lock_name is a 2-arity proc, it receives (base_class, instance)
so callers can derive per-instance lock names (e.g. by tenant/scope column).
1-arity procs continue to receive only base_class - fully backward compatible.

Instance-method call sites pass self; class-method sites pass nil, falling
back to the model-wide lock name as before.

Co-authored-by: Masanori OKAZAKI <masanori-okazaki@freee.co.jp>
@seuros seuros merged commit a7a554c into master May 6, 2026
8 checks passed
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.

Trying to add 2 nodes simultaneously to closure_tree table results in a deadlock

1 participant