Sanitize reused PostgreSQL connections at checkout - #1752
Draft
Zetazzz wants to merge 1 commit into
Draft
Conversation
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
DISCARD ALLpool.query()checkout behavior while leaving alternate registered pool factories unchangedThis implements F10 from constructive-io/constructive-planning#1693. It is stacked directly on #1744 because F02 establishes the complete transaction-local request context after F10 restores the reused connection to PostgreSQL defaults.
Scope
The change is owned by
pg-cacheand applies automatically to its default real PostgreSQL pool. It does not add pool identity, runtime/control credential separation, custom-driver sanitation, checkout telemetry, or other functionality from the original research PR.The Graphile prepared-statement cache is deleted without invoking its disposer because
DISCARD ALLhas already removed server-side statements; running asynchronousDEALLOCATEcallbacks afterward could race the next checkout.Validation
pnpm --filter pg-cache test --runInBand— 24 tests passedpnpm --filter pg-query-context test --runInBand— 13 tests passed against real PostgreSQLpnpm --filter pg-cache buildpnpm --filter pg-query-context buildpnpm install --frozen-lockfilegit diff --checkThe integration coverage proves same-backend session reset, named prepared-statement reuse with changed SQL, F02 context application after sanitation, direct
pool.query()sanitation, and fail-closed replacement of a connection left in an open transaction.pnpm policy:checkis currently blocked by pre-existing expired repository exceptions for@typescript-eslint/eslint-plugin,@typescript-eslint/parser, and@types/semver; this PR does not alter those policies.