Skip to content

Expose Postgres integer lock id #84

Description

@semaperepelitsa

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;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions