Bound SQLite startup contention and serialize schema migration #6

Merged
adam merged 1 commit from codex/sqlite-concurrent-startup into main 2026-10-22 00:00:54 -04:00
Owner

Concurrent DNS-store startup can exhaust the five-second WAL retry window while another process is initializing the database. The Fleet identity build failed with seven SQLITE_BUSY errors in TestSQLiteConcurrentOpenMigratesOnce; that test took 16.89 seconds. The precise CI interleaving has not been reproduced, but a separate process holding the database writer for six seconds reproduces the same startup failure against the current main branch.

Give configuration and migration one 30-second contention budget, with context-aware waiting and no nested SQLite busy wait. Verify that WAL was actually selected. Acquire the SQLite writer before schema inspection and commit the complete migration atomically, so concurrent services see the committed schema and failed migrations do not publish partial tables. Normal operations retain the five-second busy timeout, synchronous=FULL, foreign-key enforcement and existing shared-file permissions. Non-contention errors still fail immediately; the database schema and idempotency contract are unchanged.

Validation: the full DNS Go test suite and store race tests pass using Go 1.26.5 and the locked vendor dependencies. Regression tests cover a six-second lock held by another process, expiration while a lock remains held, reopening after failure, invalid-database preservation, concurrent legacy migration with exact response retention, and atomic rollback after a migration error. The lock-release and atomic-rollback tests both fail against cd518bf and pass with this change. Existing required CI jobs and their timeouts are unchanged. Deployment and Fleet dependency-pin updates follow only after the protected CI gates pass and this change merges.

Concurrent DNS-store startup can exhaust the five-second WAL retry window while another process is initializing the database. The Fleet identity build failed with seven `SQLITE_BUSY` errors in `TestSQLiteConcurrentOpenMigratesOnce`; that test took 16.89 seconds. The precise CI interleaving has not been reproduced, but a separate process holding the database writer for six seconds reproduces the same startup failure against the current main branch. Give configuration and migration one 30-second contention budget, with context-aware waiting and no nested SQLite busy wait. Verify that WAL was actually selected. Acquire the SQLite writer before schema inspection and commit the complete migration atomically, so concurrent services see the committed schema and failed migrations do not publish partial tables. Normal operations retain the five-second busy timeout, `synchronous=FULL`, foreign-key enforcement and existing shared-file permissions. Non-contention errors still fail immediately; the database schema and idempotency contract are unchanged. Validation: the full DNS Go test suite and store race tests pass using Go 1.26.5 and the locked vendor dependencies. Regression tests cover a six-second lock held by another process, expiration while a lock remains held, reopening after failure, invalid-database preservation, concurrent legacy migration with exact response retention, and atomic rollback after a migration error. The lock-release and atomic-rollback tests both fail against `cd518bf` and pass with this change. Existing required CI jobs and their timeouts are unchanged. Deployment and Fleet dependency-pin updates follow only after the protected CI gates pass and this change merges.
Bound SQLite startup contention and serialize schema migration
All checks were successful
CI / Formatting, unit tests, and module evaluation (pull_request) Successful in 3m28s
CI / ARM64 DNS packages (pull_request) Successful in 2m59s
CI / Seven-VM DNS topology and canonical report (pull_request) Successful in 7m4s
75cb882b8e
adam merged commit 375e834a92 into main 2026-10-22 00:00:54 -04:00
Sign in to join this conversation.
No description provided.