Skip to content

fix(index): serialise schema migrations per process - #606

Merged
ajianaz merged 2 commits into
developfrom
fix/schema-migration-race-604
Oct 9, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/schema-migration-race-604

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

What

run_migrations takes a process-wide mutex so concurrent connections to the same index file cannot race between reading schema_version and applying a migration.

Why

UNIQUE constraint failed: schema_version.version made commands::watch::tests::filtered_reindex_* fail in about 1 of 3 full test runs, locally and in CI (#604), blocking unrelated PRs. Parallel tests share one scratch index DB per process.

Testing

New test migrates one fresh DB file from 8 barrier-synchronised threads, 40 rounds: it fails with the UNIQUE error without the lock and passes with it. Full suite 8/8 green locally (was ~1/3 failing). fmt and clippy -D warnings pass.

Closes #604

🤖 Generated with Claude Code

ajianaz and others added 2 commits October 8, 2026 16:30
…y_timeout first (#604)

CI hit 'database is locked' on PRAGMA journal_mode after the migration lock
alone removed the UNIQUE race.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@ajianaz
ajianaz merged commit 1585cfe into develop Oct 9, 2026
14 checks passed
@ajianaz
ajianaz deleted the fix/schema-migration-race-604 branch October 16, 2026 00:43
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.

test: commands::watch::tests::filtered_reindex_* is flaky (UNIQUE constraint failed: schema_version.version)

1 participant