fix(depot): fix migrating v1 -> v2 databases#5183
Conversation
|
Stack for rivet-dev/rivet
Check out this stack: |
Code ReviewSummaryThis PR changes the v1->v2 SQLite migration from a hard-fail-on-sidecar strategy to a best-effort approach that logs and abandons sidecars. The change unblocks actors that crashed mid-transaction from being permanently stuck on v1. Data integrity consideration for crash-mid-commitThe journal test case exercises the scenario where the actor is killed before committing — in that case the main file still holds the last committed state, and abandoning the journal is safe. However, DELETE-mode SQLite also creates a journal when committing: it backs up original pages to the journal first, then writes new pages to the main file, then deletes the journal. If the actor process crashes between those two steps (journal exists, main file has partially new pages), the main file is in a torn state. Importing it as-is would produce a corrupted v2 database with a mix of old and new pages. The original code blocked migration in this case rather than risk importing a corrupt file. The new code accepts it. This is probably the right trade-off operationally (stuck actors are worse than a rare corrupt-on-disk state), but the existing comment in // Best-effort: import the main file as-is, discarding any sidecar. For
// the pre-commit crash case the main file reflects the last committed
// state. For the rare mid-commit crash the main file may be partially
// torn; the actor restarts with a corrupted database rather than being
// permanently blocked on v1.Orphaned sidecar data
Redundant
|
No description provided.