Skip to content

Worth using pg_try_advisory_xact_lock for PostgreSQL? #14

Description

@gaffneyc

I recently added the gem to a project and we ran into a case where the locks were not getting freed due to the transaction being aborted when it hit a configured statement timeout. When the abort occurred ActiveRecord would throw PG::InFailedSqlTransaction when trying to do the unlock.

We monkey patched in pg_try_advisory_xact_lock which auto releases at the end of the transaction and it has been working well so far. I'm fairly new to advisory locks so there might be a reason not to use them. From what I understand the main issues are that pg_try_advisory_lock will work outside of a transaction and pg_try_advisory_xact_lock is only supported in PostgreSQL 9.1 and up.

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