Skip to content

fix: harden SQLite schema_metadata migration races#591

Merged
svarlamov merged 1 commit intomainfrom
codex/fix-590-concurrent-migrations
Feb 26, 2026
Merged

fix: harden SQLite schema_metadata migration races#591
svarlamov merged 1 commit intomainfrom
codex/fix-590-concurrent-migrations

Conversation

@svarlamov
Copy link
Member

@svarlamov svarlamov commented Feb 26, 2026

Summary

  • make schema version updates idempotent with UPSERT in both internal and metrics DB migration flows
  • keep version updates monotonic to avoid downgrading when multiple initializers race
  • add regression tests that simulate partial migration state where target tables already exist before migration runs

Why

Issue #590 reports table cas_cache already exists during startup migration. IF NOT EXISTS handles table/index creation, and this patch also removes version-row write races that can still occur when multiple processes initialize simultaneously.

Testing

  • cargo test --lib handles_preexisting

Fixes #590

@git-ai-cloud-dev
Copy link

Stats powered by Git AI

🧠 you    ████████████████████  100%
🤖 ai     ░░░░░░░░░░░░░░░░░░░░  0%
More stats
  • 0.0 lines generated for every 1 accepted
  • 0 seconds waiting for AI

AI code tracked with git-ai

@git-ai-cloud
Copy link

git-ai-cloud bot commented Feb 26, 2026

Stats powered by Git AI

🧠 you    ████████████████████  100%
🤖 ai     ░░░░░░░░░░░░░░░░░░░░  0%
More stats
  • 0.0 lines generated for every 1 accepted
  • 0 seconds waiting for AI

AI code tracked with git-ai

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@svarlamov svarlamov changed the title fix: harden SQLite migration startup races fix: harden SQLite schema_metadata migration races Feb 26, 2026
@svarlamov svarlamov merged commit 51a0b49 into main Feb 26, 2026
23 checks passed
@svarlamov svarlamov deleted the codex/fix-590-concurrent-migrations branch February 26, 2026 15:09
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.

[Error] Failed to initialize internal database: SQLite error: table cas_cache already exists

1 participant