Skip to content

fix: parallel first opens no longer fail with 'database is locked'; link check tolerates GitHub 503s - #163

Merged
vsn411 merged 4 commits into
mainfrom
fix/wal-switch-lock
Nov 20, 2026
Merged

vsn411 merged 4 commits into
mainfrom
fix/wal-switch-lock

Conversation

@vsn411

@vsn411 vsn411 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Two flaky checks found while reviewing #162.

Parallel first opens fail with database is locked

RunRepository switches the file to WAL on every open. On a new database, or one that isn't in WAL mode yet, that switch needs an exclusive lock. SQLite returns database is locked for it immediately instead of waiting out busy_timeout. When several skills open such a database at the same moment, about 1 open in 20 failed. The #159 test test_runs_status_migration_is_idempotent_and_safe_under_concurrent_opens hit this intermittently.

CI on Python 3.10 then showed a second error from the same race: database schema has changed, raised while another connection is creating the tables. Every setup step is idempotent (CREATE ... IF NOT EXISTS, race-safe column adds, a rebuild that re-checks under its lock). So the whole setup now retries on a fresh connection for either error, for up to 10 seconds; any other error raises at once. WAL persists in the file, so only the first open ever switches it.

Tests:

  • test_parallel_first_opens_never_fail: 25 rounds of 6 threads released together by a barrier, for a missing database and an old one. Without the fix both cases fail on every run. On failure it prints the tracebacks.
  • Deterministic tests inject each error and check that setup retries on a new connection and closes the old one, that other errors are not retried, and that setup gives up at the deadline.

Link check fails on github.com 503s

The Docs (links, version) job turned main red twice today, with 1 and 18 "errors", all 503 Service Unavailable on github.com blob pages that exist. GitHub throttles those pages when Actions runners crawl them. 502 and 503 are now accepted; a broken link is a 404, which still fails the job.

Verification

  • Full suite: 1877 passed. The one failure is tests/test_sensor/test_python_probe.py::test_sensor_dying_mid_run_drops_events_without_blocking, which fails locally on macOS, on main too. It is not touched here, and CI on Linux passes it.
  • ruff check on the touched files: no new findings.

🤖 Generated with Claude Code

Satyanarayana Vuppala and others added 4 commits November 20, 2026 18:31
Switching a database to WAL takes an exclusive lock, and SQLite returns
'database is locked' for it at once instead of honouring busy_timeout.
Several skills opening a new or pre-WAL database at the same moment
failed about 1 open in 20; the #159 concurrency test hit it
intermittently. The switch now retries briefly. WAL persists in the
file, so only the first open ever switches it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github.com throttles blob pages crawled from Actions runners with 503,
which turned main red twice on 2026-11-20 with 1 and 18 'errors' on
pages that exist. A broken link is a 404, which still fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI (Python 3.10, Linux) showed parallel first opens of a new database
can also fail with 'database schema has changed' while another
connection creates the tables, not only with the WAL switch's
'database is locked'. Every setup step is idempotent, so the whole
setup is now retried on a fresh connection for either error, until a
10-second deadline; any other error raises at once. Deterministic tests
inject each error; the parallel stress test now prints the failing
tracebacks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
assert repo._conn is connections[-1]
assert repo._conn.execute("SELECT count(*) FROM runs").fetchone()[0] == 0
finally:
repo.close()
@vsn411
vsn411 merged commit 36a3534 into main Nov 20, 2026
10 checks passed
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