Skip to content

fix(migration): handle pipeline-incompatible statements in ExecBatch#5156

Open
wucm667 wants to merge 1 commit intosupabase:developfrom
wucm667:fix/db-reset-multi-statement-pipeline
Open

fix(migration): handle pipeline-incompatible statements in ExecBatch#5156
wucm667 wants to merge 1 commit intosupabase:developfrom
wucm667:fix/db-reset-multi-statement-pipeline

Conversation

@wucm667
Copy link
Copy Markdown
Contributor

@wucm667 wucm667 commented May 1, 2026

Fixes #5139

What type of PR is this?

  • bug

What this PR does / why it is needed:

When running supabase db reset, migrations containing CREATE INDEX CONCURRENTLY fail with SQLSTATE 25001 ("cannot be executed within a pipeline"). This is because ExecBatch in pkg/migration/file.go sends all statements through conn.PgConn().ExecBatch(), which uses PostgreSQL's extended query protocol pipeline — incompatible with CONCURRENTLY, VACUUM, REINDEX CONCURRENTLY, ALTER SYSTEM, and CLUSTER statements.

The fix:

  • Added isPipelineIncompatible() to detect statements that cannot run in a pipeline
  • Modified ExecBatch to flush the batch before these statements and execute them individually via conn.Exec (simple query protocol), then resume batching for subsequent statements
  • The version record is inserted at the end of the flush, only after all statements succeed

Testing

Manual testing with a migration file containing CREATE INDEX CONCURRENTLY confirms the fix — the statement now executes successfully via simple protocol while other statements continue to benefit from pipelining.

CREATE INDEX CONCURRENTLY, REINDEX CONCURRENTLY, and VACUUM cannot run
inside a pgx pipeline (extended query protocol). When db reset encounters
these statements, the batch fails with SQLSTATE 25001.

Fix: detect pipeline-incompatible statements and execute them individually
via conn.Exec (simple query protocol) while batching the rest normally.

Fixes supabase#5139

Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
@wucm667 wucm667 requested a review from a team as a code owner May 1, 2026 01:41
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.

supabase db reset fails on multi-statement migrations (42601) and CONCURRENTLY in pipeline (25001)

1 participant