-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for locking table in pgx-driver #992
Conversation
In order to support running migrations through PgBouncer which does not support advisory locks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsfcode Thanks for the PR and for explaining why it's needed!
Did you have plans to also make this change to the postgres driver? (You don't need to)
I don't have any plans to add it to the postgres driver, since we only use the pgx driver at the moment. |
Defer rollback of transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsfcode Thanks for addressing the PR feedback!
A common pattern in postgres deployment is to use pgbouncer in transaction pooling mode. This is to support at large number of concurrent clients to work around the process based postgres connection model.
Unfortunately pgbouncer does not support advisory locks in transaction pooling mode, which is the most commonly used mode. To work around this we introduce this traditional table lock method. As used in the cockroach driver. We expose the feature behind a config flag and default the config to advisory lock.