postgres: disable the session timeouts that cancel COPY - #6
Merged
Conversation
A COPY part is one statement and holds its transaction until it finishes. So are pg_dump and pg_restore. Inherited statement_timeout, lock_timeout, idle_in_transaction_session_timeout, and idle_session_timeout cancel that work with SQLSTATE 57014, and pgmigrate never cleared them. Every SQL session it opens now sets those four GUCs to 0 before BEGIN. pg_dump and pg_restore get the same via PGOPTIONS. Preflight warns when the inherited values are non-zero, so they are visible before a long run; pgmigrate does not ALTER ROLE for itself. 57014 is still not retried: after the timeouts are off, a cancel is external. --retry-base-copy is not the fix for that. Closes #5. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A COPY part,
pg_dump, andpg_restoreare each one statement, and a COPY part holds its transaction until it finishes. Inheritedstatement_timeout,lock_timeout,idle_in_transaction_session_timeout, andidle_session_timeoutcancel that work with SQLSTATE 57014.SETs those four GUCs to 0 beforeBEGIN(postgres.Connect). Replication connections are unchanged.pg_dump/pg_restoreget the same viaPGOPTIONS.ALTER ROLE.pg_cancel_backend, a proxy idle timeout).--retry-base-copyis not the fix for that.Closes #5.
Test plan
gofmt,vet, unit tests, racestatement_timeoutis SET to 0,pg_sleepsurvives, preflight warns and stays acknowledgeable, COPY of a table completes understatement_timeout=1msmake e2e(migration-e2e=ok)Made with Cursor