perf: reuse Postgres pools for connect#141
Merged
Merged
Conversation
Contributor
Greptile SummaryThis PR changes Postgres connections to reuse shared pools while keeping logical handles separate. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "fix: enforce Postgres handle tokens" | Re-trigger Greptile |
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
std/db/postgres.connect(url)reuse a process-local shared pool keyed by connection stringconnect(url)call returning a fresh logical handle, with transaction state isolated per handleclose(handle)to invalidate only that logical handle while keeping the shared URL pool cachedpostgres_connect_in_functionlint and update docs/generated stdlib referencesApp compatibility scan
Scanned Larri-owned ntnt apps/repos under
/home/larimonious/appsand/home/larimonious/reposforstd/db/postgresimports and aliased calls.Findings:
connect()handles already: larri-net, ntnt-lang-org, TAP, Running Wild, Panamera Hub, site templates, etc.pg_connect/pg_closepath inlib/dashboard_signals.tnt; this PR directly fixes that churn.connect → query → close; this now hits the shared pool fast path.close()destroying the underlying URL pool.Verification
cargo build --profile dev-releasecargo test -q— 1165 unit tests plus integration suites passing./target/dev-release/ntnt validate examples/— all 57 examples valid, existing 6 warnings./target/dev-release/ntnt lint examples/— existing warnings/suggestions onlyconnect(url)calls stayed atactivity_count=1close(handle)invalidated the logical handle withInvalid or closed database connectiongit diff --check