Repository navigation
Conversation
Owner
|
Thanks for this! The Postgres module-singleton / "connect() has not been called" ownership bug was fixed canonically in #1805 (atomic owner-only-disconnect), with follow-ups in #1608 and #1572 — all merged to master. Closing as already-resolved. If you still reproduce after upgrading, please reopen, and thank you for the contribution. |
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
This fixes a Postgres connection-lifecycle bug where short-lived helper engines could tear down the shared module-level database pool that the main
gbrain dreamcycle still needed.In the dream cycle, lint runs early and briefly opens an engine to lift DB-backed content-sanity config. On Postgres, that helper can reuse the existing module-level singleton. Before this change, its
disconnect()path always calleddb.disconnect()for module-mode engines, even when the helper did not create the singleton. That leaves later phases withNo database connection/connect() has not been called.Issue cluster
Fixes #1492.
Fixes #1471.
Fixes #1499.
Those reports converge on the same root cause: an early lint/config helper borrows the shared Postgres module singleton, then disconnects it out from under the still-running dream cycle or worker pool.
This also targets the same Postgres "later phase loses the DB connection after an earlier helper phase ran" symptom cluster reported in #1491, #1515, #1531, #1462, and #1422. I am not marking every adjacent report as auto-closed because some include follow-on error-reporting, worker-startup, idle-timeout, or phase-specific details, but this PR removes the shared-pool teardown bug they converge on.
Related but likely separate: #1426 appears to involve PGLite pending-write lifecycle behavior, so this PR does not claim to fix it. #1404 and #1413 have overlapping
connect() has not been calledevidence, but their later comments also discuss additional lifecycle paths outside this narrow ownership fix.Why this matters
This is a small lifecycle fix with high operational impact:
For Postgres users, this turns a whole class of hard-to-diagnose dream-cycle crashes back into stable multi-phase runs without changing query semantics or pool setup.
What changed
PostgresEngine.disconnect()so module-mode borrowers do not calldb.disconnect().Validation
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:54322/<scratch-db> bun test test/e2e/postgres-engine-disconnect-idempotency.test.tsbun test test/cli-dream-engine-warn.test.ts test/dream.test.tsbun run typecheckgit diff --checkgit show --check HEADscripts/check-no-double-retry.sh && scripts/check-batch-audit-site.sh && scripts/check-test-isolation.shgitleaks dir . --redact --no-bannergitleaks git . --redact --no-banner --log-opts="origin/master..HEAD"