Recover missing /content items after restart#311
Recover missing /content items after restart#311arubi9 wants to merge 1 commit intonzbdav-dev:mainfrom
Conversation
@arubi9, the sqlite database is the source of truth. It's odd that you're seeing rows randomly go missing from the DavItems table after a reboot. We should find the root cause of that, rather than trying to build around it. What do your volume mappings look like? |
|
volumes:
So after a reboot, What I’m seeing is narrower: the database file survives, and other DB-backed state survives, but some The reason I proposed this PR is that the user-facing failure mode is severe: |
|
Ty for clarifying! Are you able to reproduce the missing rows issue pretty consistently? I'm wondering if something may be going on with the sqlite write-ahead-log (wal file). If the nzbdav container isn't gracefully shut down, then WAL contents might not get a chance to sync to the main db.sqlite file. However, this shouldn't be a problem as long as the WAL file persists after reboot. It should sync to the main db.sqlite next time nzbdav starts up. Could the WAL file be getting corrupted? If you're able to reproduce the missing rows issue, could you check whether the WAL file is present in the |
Fixes #304.
/contentis a database-backed WebDAV view, not a real media folder on disk. If nzbdav starts after a reboot with/contentrows missing fromdb.sqlite, the files appear to disappear even though the app did not intentionally delete them.This change adds a guarded recovery path:
/contentsubtree and its file metadata under/config/contentrows and matching file metadata at startup when the DB is empty or partially missingHealthy startup behavior is unchanged, and intentional deletes stay deleted because valid post-delete snapshots replace the prior state.
Tests cover:
/contentstarts emptyValidation:
dotnet build backend/NzbWebDAV.csprojdotnet test backend.Tests/backend.Tests.csprojThis does not recover anything if
/configitself is not persistent, because both the DB and the recovery snapshot are gone in that case.