Skip to content

Add support for locking table in pgx-driver - #992

Merged
dhui merged 3 commits into
golang-migrate:masterfrom
fortnox-andreas:master
Dec 20, 2023
Merged

dhui merged 3 commits into
golang-migrate:masterfrom
fortnox-andreas:master

Conversation

@tsfcode

@tsfcode tsfcode commented Oct 19, 2023

Copy link
Copy Markdown

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.

fortnox-andreas and others added 2 commits September 20, 2023 09:59
In order to support running migrations through PgBouncer which does not
support advisory locks.
@coveralls

coveralls commented Oct 19, 2023 •

Copy link
Copy Markdown

Coverage Status

coverage: 59.183%. first build
when pulling 091ad5d on fortnox-andreas:master
into 691f687 on golang-migrate:master.

@dhui dhui left a comment

Copy link
Copy Markdown
Member

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)

Comment thread database/pgx/pgx.go Outdated
Comment thread database/pgx/pgx.go
Comment thread database/pgx/pgx.go Outdated
@tsfcode

tsfcode commented Dec 20, 2023

Copy link
Copy Markdown
Author

@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

@dhui dhui left a comment

Copy link
Copy Markdown
Member

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!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants