Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Postgres integer lock id #84

Open
semaperepelitsa opened this issue Jan 3, 2024 · 0 comments
Open

Expose Postgres integer lock id #84

semaperepelitsa opened this issue Jan 3, 2024 · 0 comments

Comments

@semaperepelitsa
Copy link

semaperepelitsa commented Jan 3, 2024

At the moment, the gem generates lock id automatically based on the given string. The resulting lock id is hidden as an implementation detail. However, it would be useful to know for debugging purposes - to see which DB session is holding the current lock, in case it is stuck, and be able to force-release it.

Here is how it could work:

info = User.with_advisory_lock_result("user-#{user.id}"){ ... }
unless info.lock_was_acquired?
  p info.lock_id #=> [2116437524, 0]
end
select * from pg_locks where classid = 2116437524;
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

No branches or pull requests

1 participant