Repository navigation
test(api): Lucid 22.5, tests without a global transaction, ready for pg 9 - #123
Merged
Merged
Conversation
…pg 9 Lucid 22.5 runs a query's preloads one after the other inside a transaction (adonisjs/lucid#1200), so the roadmap item and the Dependabot hold on pg's major go. The pg warning stayed: the tests wrapped each one in a global transaction, so the queries the app runs at the same time (Promise.all, the assistant's tool calls) queued on its one connection, which pg 9 refuses. In production each of them takes its own pool connection. - tests/helpers/database.ts `emptyDatabase` deletes the rows a test wrote, after it, children first, in one round trip (TRUNCATE made the suite half again as slow); every group uses it. - The test database runs with synchronous_commit off, so committing every write keeps the suite at its old time (29 s). - The assistant tests read tool outputs by tool name: tools of one step finish in any order.
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
Lucid ran a query's preloads in parallel. Inside a transaction, pg queued them on the one connection and warned that pg 9 will refuse it, so Dependabot held pg's major back. Lucid 22.5 fixed that (adonisjs/lucid#1200), but the warning stayed in the API tests. Each test ran inside a global transaction, so the queries the app runs at the same time (
Promise.allin the order detail, the assistant's tool calls of one step) also queued on one connection. Production was never affected: there each query takes its own pool connection. Under pg 9 those tests would fail.What
emptyDatabase(tests/helpers/database.ts) deletes the rows a test wrote, after it: one query finds the tables with rows, one round trip deletes them, children first. Every group uses it. Lucid'stestUtils.db().truncate()made the suite 46 s instead of 29 s.synchronous_commitoff (only whenNODE_ENV=test, inconfig/database.ts). Now that every write commits, this keeps the suite at its old time.apps/api/AGENTS.mddescribes the cleanup and why there's no global transaction.Tests
pnpm checkpasses twice in a row: 323 API tests in 29 s, no pg deprecation warning (also checked with--trace-deprecation).Deploy notes
No migrations or new environment variables.