Find and fix database connection leaks in API

Task 13650 · Done · Coder · created · updated

Some API tests leave a database connection open and idle inside a transaction. When a later DBOS launch in the same xdist worker runs its CONCURRENTLY index migration, it hangs on that connection. Task 13639 neutralised this: `end_leaked_transactions()` in apps/api/tests/nodevault_support.py ends such connections before every DBOS launch and warns. The leaking tests themselves are still unfixed. In a full `./dc test -q -n 8` run, the gate's warnings summary named these leaks ("ended a connection leaked idle in a transaction"): - a connection whose last query was `UPDATE merge_lane_rows SET state=…, note=…` (merge-lane route or service tests), idle for about 2 minutes; - two connections whose last query was `SELECT identities.id …`, found at token_billing/test_outbox's launch. Ask: find the tests that leave these sessions open, and close or roll back each one. Out of scope: removing `end_leaked_transactions()`, because it guards against future leaks. Done means: two consecutive full `./dc test -q -n 8` runs show no "ended a connection leaked idle in a transaction" warning; `./dc check quick` green.

Outcome

Closed the sessions 4 API tests left idle in a transaction (merge-lane UPDATE, 2× browser_stream identities, compliance ar_pack_id fixture, virtual_nodes). 2 full -n 8 runs: 0 leak warnings; quick green. PR #7963 queued. Memory: none applied.

Pull request

Artifacts

Activity

  • Created
  • Run
  • Runner started
  • Runner ended (done)