Skip to content

No rollback / checkpoint mechanism for partial migration failures #1721

Description

@Widthdom

Summary

ClearReadyFlags() (DbContext.cs:560-563) is called at the start of every index run to demote trust if the run crashes — that's good for read-side correctness. But there is no way to roll back to the prior known-good state if a schema migration or backfill-fold partially completes and corrupts the DB. The user's options are: rebuild from scratch (hours of work) or manually salvage with sqlite3 shell. There is no cdidx db checkpoint or cdidx db restore command.

Where

  • src/CodeIndex/Database/DbContext.cs:560-563 (ClearReadyFlags — no checkpoint complement)
  • src/CodeIndex/Cli/IndexCommandRunner.cs:285-380 (RunBackfillFold — no pre-flight snapshot)

Suggested approach

(1) Before destructive maintenance (backfill-fold, schema migration, --rebuild), automatically take a sidecar snapshot to <db>.checkpoint-<timestamp> (hardlink if same filesystem, otherwise file copy gated by --no-checkpoint opt-out). (2) Add cdidx db checkpoint <name> for explicit named checkpoints. (3) Add cdidx db restore <name> that atomically swaps the snapshot in. (4) Add cdidx db checkpoints --list to enumerate. (5) Auto-prune checkpoints older than N days (configurable). (6) Document in DEVELOPER_GUIDE under "Maintenance".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions