0xMiden / 0xMiden/note-transport-service

Fail-open database creation silently starts an empty DB

Offen
#124 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug production-readiness
Vorherrschende Sprache
Rust
Sterne
3
Forks
10
Ø Merge
2 Std. 23 Min.
Gemergte PRs (30 T.)
4

Beschreibung

Severity: high.

### Summary

`connect()` calls `std::fs::File::create(&config.url)` whenever the path does not exist (`crates/node/src/database/sqlite/mod.rs:86-90`). Combined with `seq INTEGER PRIMARY KEY AUTOINCREMENT`, a fresh file restarts the sequence at 1.

### Impact

Any wrong `--database-url`, unmounted Docker volume, or deleted file yields a brand-new empty database with a regressed sequence space — silently, with migrations auto-running and no loud log. This is a distinct trigger for the #101 dead band from the `:memory:` default (#112): it bites even with a correct-*looking* file URL. Clients holding a persisted cursor above the new high-water fetch zero notes for the skipped range, permanently.

### Recommendation

- Fail startup if the file does not exist unless an explicit `--create-database` (or first-run) flag is passed.
- Persist a DB instance/epoch identifier and expose it (e.g. in `FetchNotesResponse`) so clients can detect a sequence-space reset and restart from 0 — this is the client-side recovery path #101 calls for.

Related: #101, #112.

---
Part of #114.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

The issue points to `crates/node/src/database/sqlite/mod.rs:86-90` where `connect()` creates a file if missing. Start by examining that function and the surrounding database initialization logic. Understand how the `--database-url` is parsed and used. The fix involves adding a startup check for file existence and potentially a new flag like `--create-database`. Also consider adding a DB epoch identifier as mentioned. Run existing tests related to database connectivity to ensure changes don't break current behavior.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust, sqlite
Bereich
backend, database
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
65/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.