ops: document a consistent backup procedure; cp of a live WAL database is unsafe #153
Labels
No labels
kind
bug
kind
enhancement
wayfinder
grilling
wayfinder
map
wayfinder
prototype
wayfinder
research
wayfinder
task
workflow
needs-info
workflow
needs-triage
workflow
ready-for-agent
workflow
ready-for-human
workflow
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rosa/vernier#153
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found during a pre-production review.
Location: ADR-0016 (
docs/adr/0016-vernier-stores-its-data-in-sqlite.md), ADR-0017 (docs/adr/0017-media-is-stored-as-optimized-blobs-in-sqlite.md); pool config atcrates/infra/src/repositories/sqlite.rs:44Severity: Data-loss risk — production operability
Problem
Both ADRs document the backup procedure as
cp vernier.db somewhere. The pool opens the database in WAL mode (crates/infra/src/repositories/sqlite.rs:54), so a plaincpof the main DB file while the server is running is not a consistent snapshot: it can capture a torn file (a checkpoint mid-flight), and it omits the-waland-shmsidecars that hold not-yet-checkpointed committed transactions. A restore from such a copy can be stale or corrupt.This is the highest-stakes gap for going to production: media are stored as blobs in the same database (ADR-0017), so this one file is the entire instance. A bad backup loses posts, accounts, and all media at once.
Suggested fix
Give operators a consistent-snapshot path and document it in place of
cp. Options, roughly in order of upkeep:VACUUM INTO 'backup.db'orsqlite3 vernier.db ".backup 'backup.db'"— online, consistent single-file snapshot; easy to cron. Lowest-friction fit for the "small box" goal.At minimum, update ADR-0016/0017 and the README so no one relies on
cpof a live WAL database. Consider whether a built-in snapshot command (or a documented one-liner) is warranted so backup doesn't require the operator to know SQLite internals.Agent Brief
Category: bug
Summary: Replace the unsafe
cp vernier.dbbackup guidance with a consistent-snapshot procedure in the ADRs and README.Current behavior:
The project's operator documentation prescribes backup as copying the SQLite database file (
cp vernier.db somewhere). This appears in the SQLite storage ADR, the media-blob storage ADR, and the README. The running server opens the database in WAL journal mode, so a file copy taken while the server is live is not a consistent snapshot: committed transactions that still live in the-walsidecar are omitted, and a copy taken mid-checkpoint can be torn. Because media are stored as blobs in this same database, the file is the entire instance — a bad restore loses posts, accounts, and media together.Desired behavior:
The documentation describes a backup procedure that produces a consistent single-file snapshot of a live WAL-mode database, and no longer instructs operators to
cpthe database file. Use SQLite's online backup —VACUUM INTO 'backup.db'orsqlite3 <db> ".backup 'backup.db'"— and explain briefly why a rawcpis unsafe under WAL so the reasoning is durable. Restore is copying the snapshot back into place while the server is stopped. Keep it to a documentation change: a one-liner an operator can cron.Key interfaces:
Acceptance criteria:
cp/copying the live database file.VACUUM INTOor.backup) and a matching restore note.Out of scope: