Skip to content

Nothing ever checks the database is still sound #37

Description

@vmillet-dev

Nothing ever asks SQLite whether the file is still sound. There is no PRAGMA integrity_check, no quick_check, nowhere. Corruption is discovered the day a query fails — which is the worst possible moment, because by then every backup taken since it started is a copy of a broken file.

That is what couples this to the automatic-backup issue: a backup strategy without an integrity check does not protect the library, it propagates the damage on a schedule.

Shape:

  • PRAGMA quick_check at startup rather than integrity_check. The quick variant skips the most expensive cross-checks and is fast enough to run on every launch on a database this size; the full check belongs behind a button, not on the startup path.
  • On failure, say so before the user writes anything else, and point at the file. Silently carrying on is how a salvageable database becomes an unsalvageable one.
  • The recovery path matters more than the detection: offer to move the damaged file aside and start fresh, so the user is not stuck in a loop with an app that refuses to open. VACUUM INTO on a partly-readable database often rescues most of it and is worth trying before giving up.

Where it belongs: the same place the storage failure is reported at startup — the two share a dialog and a decision ("what do I do with a database I cannot use?").

Note on cost: quick_check reads the whole file. On a small library that is milliseconds; if the corpus ever grows to the sizes discussed in the canvas-loading issue, this should move to a background check or a periodic one rather than every launch.

Done when: a corrupted database is named as such instead of surfacing as a random command failure, and the user has a way out that does not involve deleting a file by hand.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions