spindle icon indicating copy to clipboard operation
spindle copied to clipboard

Open connection to Navidrome's database prevents its WAL file from being cleaned up

Open snail-boi opened this issue 4 weeks ago • 1 comments

Summary

While Spindle is running, Navidrome's navidrome.db-wal is not removed when Navidrome restarts. In my setup, it had reached 1.2 GB next to a 34 MB database.

Environment

  • Spindle version: 0.4.1
  • Navidrome version: 0.64.2
  • Running in Docker, with Navidrome's data folder mounted into spindle-backend
  • NAVIDROME_DB_PATH=/nddata/navidrome.db

What I observed

  • navidrome.db was 34 MB and navidrome.db-wal was 1.2 GB.
  • After stopping Navidrome, the WAL was still there at 1.2 GB.
  • fuser showed Spindle's node dist/server.js process still had both files open.
  • After stopping Spindle first and then Navidrome, the WAL was removed.
  • navidrome.db stayed at 34 MB afterwards.

Likely cause

SQLite normally removes the WAL when the last connection closes. dist/db/navidrome-db.js opens the database read-only, and the connection appears to stay open while Spindle runs. With Spindle connected, Navidrome is never the last connection, so stopping it doesn't trigger that cleanup.

I haven't confirmed what made the WAL grow to 1.2 GB in the first place. It may have been a burst of writes, such as a library scan, rather than steady growth. Spindle's connection is read-only, and I saw no evidence of it writing to the database.

Steps to reproduce

  1. Run Navidrome and Spindle with the shared data folder.
  2. Let Navidrome's WAL grow, for example during a library scan.
  3. Stop Navidrome while Spindle is still running.
  4. Check that navidrome.db-wal is still there at the same size.
  5. Stop Spindle, start Navidrome, then stop Navidrome again.
  6. Check that the WAL is gone.

Expected behavior

Spindle's read access shouldn't stop Navidrome's WAL from being cleaned up.

Possible fix

Open the Navidrome database only when it's needed and close it after each query or batch of queries, instead of keeping one connection open. This should let Navidrome be the last connection when it shuts down.

Workaround

  1. docker stop spindle-backend
  2. Restart Navidrome.
  3. docker start spindle-backend

snail-boi avatar Nov 04 '26 00:11 snail-boi

Fixed in v0.4.2.

xmorose avatar Nov 04 '26 16:11 xmorose