-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Use DELETE FROM instead of TRUNCATE for pgx #862
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
base: master
Are you sure you want to change the base?
Conversation
|
@dhui Any updates on getting this merged? Appreciate for your time. |
ce61c79 to
6e91d4e
Compare
|
@HeroSizy @shawnzxx Sorry for the extremely slow response. I'm onboard with the change. A similar change was already made to MySQL but for different reasons. Could you also make the change to the postgres driver? Also, based on the article you linked, be aware that if there any migrations (e.g. DDL statements) that need to be applied, they'd still be blocked by the pg_dump run. |
Following this comment: golang-migrate#862 (comment) And reference PR: https://github.com/golang-migrate/migrate/pull/656/files
e29809a to
016d30d
Compare
|
Hi @dhui , apologise for the slow response, I have just updated the isolation level. And also included pgx/v5 |
016d30d to
dcba639
Compare
Following this comment: golang-migrate#862 (comment) And reference PR: https://github.com/golang-migrate/migrate/pull/656/files
dcba639 to
2168b7a
Compare
Problem
In PostgreSQL, TRUNCATE statements cannot run during a db backup.
Deployment would be blocked by
db_dumpif there would be migration to run.db_dumprequiresACCESS SHARELOCKAnd will conflict with
TRUNCATEwhich requiresACCESS EXCLUSIVELOCKSolution
Use
DELETE FROMinstead ofTRUNCATEfor clearing the table since there is only one row of recordReference
Postgres
https://www.postgresql.org/docs/current/sql-truncate.html
Article about this scenario
https://www.dbi-services.com/blog/when-we-do-a-pg_dump-and-right-afterwards-truncate-a-table-which-is-in-the-dump-what-happens/
Edits
Edit 28-Feb-2024