Skip to content

Keep migration sessions alive through long index builds - #101

Merged
ralyodio merged 1 commit into
mainfrom
repair/nichedb-migration-session-20260913
Sep 13, 2026
Merged

Keep migration sessions alive through long index builds#101
ralyodio merged 1 commit into
mainfrom
repair/nichedb-migration-session-20260913

Conversation

@ralyodio

@ralyodio ralyodio commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

After repairing geographic function lookup, the production index build still aborts at 30 seconds with ERR_POSTGRES_IDLE_TIMEOUT. Bun applies the application pool's idle timeout while a long SQL statement produces no messages. Migration advisory locks also need to stay on the database session that executes the migration.

Give each migration run a dedicated single-connection client with idle retirement disabled, then close it when the run finishes. Acquire its advisory lock before initializing the migration ledger so simultaneous fresh boots also serialize. The ordinary application pool retains its existing settings.

Validation:

  • Reproduced the old timeout against PostgreSQL 17 at 30,014ms.
  • Production Bun 1.4.0 completes a 35-second query with the dedicated connection.
  • A real PostgreSQL integration test runs two simultaneous migration attempts through the actual migrator: a 35-second statement completes, the lock remains owned by the migration session, one attempt applies the migration, and the other skips it. This passes on Bun 1.4.0 and is added to CI with PostgreSQL 17.
  • Full ordinary suite: 1,598 pass / 0 fail, with the PostgreSQL integration test run separately as above. Repository-wide Biome and git diff --check pass.

No data rewrite, manual production schema change, or migration bypass.

@ralyodio
ralyodio merged commit e13cc21 into main Sep 13, 2026
3 checks passed
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.

1 participant