Skip to content

fix(stack): keep port registry reads open while a peer commits - #7342

Open
avallete wants to merge 2 commits into
developfrom
avallete/flaky-port-registry-wal
Open

avallete wants to merge 2 commits into
developfrom
avallete/flaky-port-registry-wal

Conversation

@avallete

Copy link
Copy Markdown
Member

TL;DR

The per-user port registry (~/.supabase/ports.sqlite) now opens in WAL mode, so a peer committing reservations no longer locks other connections out of opening or reading it.

  • Network.integration.test.ts › retains dedicated assignments across network reopen failed on Windows with database is locked while opening the registry. Under the rollback journal, a peer that commits back to back holds the lock nearly all the time, and a new connection's schema read keeps losing the race until the 2s busy timeout runs out. Parallel test files that scan for ports produce exactly that write pattern. In WAL mode readers never wait on a writer. Writers still serialize through BEGIN IMMEDIATE, as before. A new integration test opens and reads the registry while a peer holds its write lock: it fails on the old code with the same database is locked error and passes with this change.
  • Tradeoff: WAL needs shared memory, so a home directory on a network filesystem is not supported for this file.

ref

spotted in: https://github.com/supabase/cli/actions/runs/40438309049/job/121972299083


Generated by Claude Code

The per-user port registry used SQLite's rollback journal, where a peer
committing reservations back to back can lock a new connection's schema
read out past the 2s busy timeout. Opening the registry in WAL mode lets
opens and reads proceed while another connection writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBEk1M3LvdWBHSeFmCJaGq
@avallete
avallete requested a review from a team as a code owner October 27, 2026 07:43

Copy link
Copy Markdown
Member Author

/ai-review


Generated by Claude Code

@avallete avallete added the run-flaky-check Run the flaky-test check on this PR label Oct 27, 2026 — with Claude
@github-actions github-actions Bot removed the run-flaky-check Run the flaky-test check on this PR label Oct 27, 2026

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by a newer AI review

🤖 AI Review

Code inspection confirms all three findings: two distinct test weaknesses and a low-impact contention case when migrating an existing registry to WAL. No findings were duplicates. Tests were not run.

Findings

Severity Location Category Sources Claim
🟡 MINOR packages/stack/src/namespace/PortReservations.integration.test.ts:18 test-reliability claude The test derives the registry path from homedir(), while the service resolves the OS account home independently. An overridden HOME can make the assertion inspect the wrong file and the peer lock a different database.
🟡 MINOR packages/stack/src/namespace/PortReservations.ts:99 error-handling claude Migrating an existing rollback-journal registry to WAL can fail under peer locks that previously allowed opening and reading the registry, and that failure aborts registry initialization.
🟡 MINOR packages/stack/src/namespace/PortReservations.integration.test.ts:18 test-coverage codex The regression test can pass after production WAL initialization is removed because it reuses a database whose WAL mode persists between runs.

Stats

Claude findings: 2 · Codex findings: 1 · Confirmed: 3 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

Both independent reviews completed; Codex reported no findings. Confirmed Claude's test-path mismatch, a low-risk shared-registry contention concern, and an import-grouping nit. No production defect was identified in the WAL initialization change.

Findings

Severity Location Category Sources Claim
🟡 MINOR packages/stack/src/namespace/PortReservations.integration.test.ts:18 test-coverage claude The test derives the registry path from homedir(), while the service resolves the OS account home independently of HOME. When those differ, the test can fail or lock a different database and pass without exercising contention.
🟡 MINOR packages/stack/src/namespace/PortReservations.integration.test.ts:23 test-reliability claude The test holds a write transaction on the shared per-user registry while reopening the service. Concurrent integration workers can exhaust their two-second writer timeout if this interval becomes slow.
⚪ NIT packages/stack/src/namespace/PortReservations.integration.test.ts:5 style claude The node:crypto and node:os imports are separated by the Effect imports.

Stats

Claude findings: 3 · Codex findings: 0 · Confirmed: 3 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: manual · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

…to WAL

SQLite does not consult the busy timeout when two connections switch a
fresh file into WAL at once, so parallel stack owners could fail to open
the registry with "database is locked". The switch now retries on busy
for up to the same 2s budget. The registry layer also takes a directory
so its test runs against a fresh, isolated database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBEk1M3LvdWBHSeFmCJaGq
@avallete avallete added the run-flaky-check Run the flaky-test check on this PR label Oct 27, 2026 — with Claude
@github-actions github-actions Bot removed the run-flaky-check Run the flaky-test check on this PR label Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Flaky test check: ✅ no flaky tests

Commit af47560b4c31 · focused ×10 (5 executions each), 8003 tests · integration ×10, 5633 tests · unit ×10, 8351 tests · workflow run

Each execution is a separate Vitest process; Where lists failing runs, as run.iteration for suites executed more than once per run. The full data is in the flaky-check-report artifact.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants