Created
September 2, 2021 17:11
-
-
Save filipechagas/f89c7ca6d2314f16e571b30fc0cf14cf to your computer and use it in GitHub Desktop.
Postgres Advisory Lock - Pessimistic application enforced lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT version, json_content, pg_try_advisory_xact_lock(s.id) as locked, s.id as id | |
FROM snapshots s | |
WHERE ar_id = $1 | |
-- from https://github.com/crabzilla/crabzilla/blob/f66e43ca4d7c119a00fab68c48386aa7672b0e95/crabzilla-engine-postgres/src/main/java/io/github/crabzilla/engine/command/CommandController.kt#L48 | |
-- more at https://hashrocket.com/blog/posts/advisory-locks-in-postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment