Environment
- LightNVR installed as a Home Assistant OS add-on
- Not observed on a separate, standalone Ubuntu/Docker install of LightNVR by the same reporter — this points toward something specific to the HA add-on environment (exact mechanism unconfirmed)
- 7 camera streams (5 ESP32/MJPEG via ffmpeg transcode, 2 native RTSP IP cameras)
backup_interval_minutes = 60 (default-ish setting)
Bug
GET /api/timeline/segments fails for every stream simultaneously with:
[ERROR] [RecordingsAPI] Failed to prepare timeline segments query: disk I/O error
[ERROR] [RecordingsAPI] Failed to get timeline segments
This repeats identically for every subsequent request (~every 10s, matching UI polling) until the LightNVR process is restarted, at which point it works again — for a while.
What's been ruled out
- Not disk/hardware.
dmesg shows no I/O errors, no remounts, no ATA errors at the failure time.
- Not DB corruption.
PRAGMA quick_check passes cleanly on the live DB.
- Specific to
prepare(), not execution. Ordinary SELECT queries against the same recordings table via the sqlite3 CLI succeed fine during the failure window.
- WAL file is not bloated (
lightnvr.db-wal was 0 bytes when checked) — rules out a naive "WAL grows huge, eventually fails" theory.
- Not a temp-storage issue.
/tmp inside the container has ample free space.
Reproducible correlation
- Process started 11:47. First failure hit 13:47 — exactly two 60-minute backup cycles later.
- Test: set
backup_interval_minutes = 0, restarted once. Timeline queries succeeded cleanly for 3+ hours straight, well past where failures previously always occurred.
- Re-enabling backups afterward is the natural next test, to confirm the failure reproduces again on schedule.
Hypothesis (unconfirmed — flagging clearly as speculative)
Periodic backup likely requires a WAL checkpoint to produce a consistent snapshot. If a timeline prepare() call executes during that checkpoint, it may hit the shared WAL index (-shm) in an inconsistent state, surfacing as "disk I/O error."
What I could NOT confirm, flagging explicitly: why the failure persists across every subsequent request instead of resolving after the one moment of actual contention. I don't have evidence for a specific mechanism (e.g., a stuck connection handle, an unreleased lock, a bad cached prepared statement) — this needs maintainer insight or source-level review of the backup implementation's interaction with concurrent connections.
Question for maintainers
Is there any known interaction between the scheduled backup (maybe_run_scheduled_database_backup() in db_core.c) and concurrently-open read connections that could produce a persistent (not self-recovering) SQLITE_IOERR on prepare() for unrelated queries, until process restart? Separately: is there anything in the HA add-on packaging/environment that could plausibly explain why this reproduces there but not on a standalone install of the same LightNVR version?
Environment
backup_interval_minutes = 60(default-ish setting)Bug
GET /api/timeline/segmentsfails for every stream simultaneously with:[ERROR] [RecordingsAPI] Failed to prepare timeline segments query: disk I/O error
[ERROR] [RecordingsAPI] Failed to get timeline segments
This repeats identically for every subsequent request (~every 10s, matching UI polling) until the LightNVR process is restarted, at which point it works again — for a while.
What's been ruled out
dmesgshows no I/O errors, no remounts, no ATA errors at the failure time.PRAGMA quick_checkpasses cleanly on the live DB.prepare(), not execution. OrdinarySELECTqueries against the samerecordingstable via thesqlite3CLI succeed fine during the failure window.lightnvr.db-walwas 0 bytes when checked) — rules out a naive "WAL grows huge, eventually fails" theory./tmpinside the container has ample free space.Reproducible correlation
backup_interval_minutes = 0, restarted once. Timeline queries succeeded cleanly for 3+ hours straight, well past where failures previously always occurred.Hypothesis (unconfirmed — flagging clearly as speculative)
Periodic backup likely requires a WAL checkpoint to produce a consistent snapshot. If a timeline
prepare()call executes during that checkpoint, it may hit the shared WAL index (-shm) in an inconsistent state, surfacing as "disk I/O error."What I could NOT confirm, flagging explicitly: why the failure persists across every subsequent request instead of resolving after the one moment of actual contention. I don't have evidence for a specific mechanism (e.g., a stuck connection handle, an unreleased lock, a bad cached prepared statement) — this needs maintainer insight or source-level review of the backup implementation's interaction with concurrent connections.
Question for maintainers
Is there any known interaction between the scheduled backup (
maybe_run_scheduled_database_backup()indb_core.c) and concurrently-open read connections that could produce a persistent (not self-recovering)SQLITE_IOERRonprepare()for unrelated queries, until process restart? Separately: is there anything in the HA add-on packaging/environment that could plausibly explain why this reproduces there but not on a standalone install of the same LightNVR version?