fix(drizzle-kit): limit Postgres introspection fanout#25
Open
joe-thom wants to merge 2 commits into05-05-fix_drizzle-kit_limit_prepared_postgres_query_concurrencyfrom
Conversation
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
04ea7ef to
a9471af
Compare
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.

Why
Datadog from repl-it-web's publish database-preparation flow shows
prepareDatabaseMigrationsfailures duringphase:introspectwithpg.Pool.waitingCountin the hundreds/thousands. The immediate quick fix in #24 gates calls beforepool.query(...), but the deeper root cause is in drizzle-kit itself:pgSerializer.fromDatabase()eagerly creates one async task per table/view.For large user schemas that can create thousands of concurrent table/view introspection tasks. Each task performs multiple catalog queries, so the pg pool queue can grow until queued acquires hit
connectionTimeoutMillis.What changed
Adds optional Postgres introspection fanout limiting:
and threads the option through to
pgSerializer.fromDatabase().fromDatabase()now uses a smallmapWithConcurrency()helper for the table and view/materialized-view introspection phases. Existing behavior is unchanged whentableConcurrencyis omitted.Test plan
pnpm --filter @drizzle-team/drizzle-kit exec vitest run tests/api.test.ts tests/pgSerializer.test.tspassedpnpm --filter @drizzle-team/drizzle-kit run tscpassedpnpm --filter @drizzle-team/drizzle-kit run buildpassedpnpm lintpassedRevertibility
Fully revertible. This is an additive API option and preserves existing behavior when
tableConcurrencyis omitted.Follow-up
After this stack is published, repl-it-web should bump
@drizzle-team/drizzle-kitand use both guards in the publish DB-preparation flow: