Skip to content

EXE-1422: make pg setup more resilient#7

Open
jacobheric wants to merge 1 commit intomainfrom
jacob/more-resilient-pg-setup
Open

EXE-1422: make pg setup more resilient#7
jacobheric wants to merge 1 commit intomainfrom
jacob/more-resilient-pg-setup

Conversation

@jacobheric
Copy link

@jacobheric jacobheric commented Mar 5, 2026

the old teardown executed all cleanup sql as a single statement. if any step failed (e.g. the replication slot was active, or a role had already been removed), the entire teardown would fail and leave resources behind. this made it impossible for users to remove and re-add their CDC integration. They'd then get errors like: replication slot "inngest_cdc" is active for PID <N (SQLSTATE 55006)" and get stuck.

Changes

  • execute each teardown step individually so that a failure in one step (e.g. role already removed) doesn't block the rest of the cleanup.
  • handle active replication slots by checking pg_replication_slots for an active PID, calling pg_terminate_backend(), and retrying the slot drop after a brief delay if needed.
  • add defer conn.Close(ctx) to avoid leaking the teardown connection.
  • best-effort cleanup for non-critical resources — privilege revocations and user/publication drops log warnings but don't fail the overall teardown if the resource is already gone.

NOTE: I vendored this into monorepo locally and tested it e2e against various failures scenarios with neon and supabase.

@jacobheric jacobheric changed the title make pg setup more resilient EXE-1422: make pg setup more resilient Mar 5, 2026
@linear
Copy link

linear bot commented Mar 5, 2026

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.

2 participants