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

Improve locking around pgroll initialization #283

Closed
andrew-farries opened this issue Feb 21, 2024 · 0 comments · Fixed by #285
Closed

Improve locking around pgroll initialization #283

andrew-farries opened this issue Feb 21, 2024 · 0 comments · Fixed by #285
Assignees
Labels
bug Something isn't working

Comments

@andrew-farries
Copy link
Collaborator

Two processes calling roll.Init simultaneously have a chance of a deadlock:

https://github.com/xataio/pgroll/blob/main/pkg/roll/roll.go#L88-L90

Advisory locking could be a solution here.

@andrew-farries andrew-farries added the bug Something isn't working label Feb 21, 2024
@andrew-farries andrew-farries self-assigned this Feb 22, 2024
andrew-farries added a commit that referenced this issue Feb 26, 2024
Make `pgroll` state initialization concurrency safe by using Postgres
advisory locking to ensure at most one connection can initialize at at
time.

See docs on Postgres advisory locking:
*
https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS
*
https://www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS

Closes #283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant