What lands
The two patches deliberately held out of v4.0.16 (#54) are back, each with empirical validation suites and (for #37) the migration that addresses its regression risk.
#40 — lazy='subquery' on Books relationships (#55, upstream #1279 by @dbraendle)
Eliminates the DetachedInstanceError class that's been intermittently surfacing as 500s when sorting/viewing books — also collapses the bulk-browse N+1.
| Metric (50 books × 3-4 relationship reads) | Before #40 | After #40 |
|---|---|---|
DetachedInstanceError on series / comments / languages / authors / data
| YES | no |
| SELECT statements emitted | 151 | 10 |
| Wall time on tmpfs sqlite | 22.8 ms | 11.7 ms |
Regression coverage: tests/integration/test_books_relationship_loading.py.
#37 — s6-setuidgid abc on ingest python workers + chown migration (#56, upstream #1290 by @haraldpdl)
The architecturally-correct fix: the web UI runs as abc so the ingest worker should too — that way newly imported books land abc:abc-owned and the web UI can delete them. Without #37, the upstream symptom is [Errno 13] Permission denied on the delete path.
The patch alone would have regressed users whose libraries already contain root:root-owned author/series subdirectories from before, so v4.0.17 also ships:
- A new oneshot s6 service
cwa-chown-library-migrationthat runs once per installation (gated by/config/.cwa-chown-library-donesentinel), aligns/calibre-libraryand/cwa-book-ingestownership toabc:abc, then no-ops on every reboot - Skipped under
NETWORK_SHARE_MODE=true(chown over NFS is slow / may be refused; logs guidance for manual migration) cwa-ingest-servicewaits for the migration before starting, so the very first ingest after an upgrade has clean ownership
Regression coverage: tests/integration/test_ingest_setuidgid_permission.py (8 tests against the real production image; demonstrates the regression empirically and verifies the migration heals it end-to-end).
NETWORK_SHARE_MODE / NFS users
If you run with NETWORK_SHARE_MODE=true, the chown migration is skipped to avoid hammering your share. Run this once after upgrading:
docker exec <container> chown -R abc:abc /calibre-library /cwa-book-ingest
(Or skip if your share's permission model already aligns with abc / PUID 1000.)
Drop-in upgrade
```
docker pull ghcr.io/new-usemame/calibre-web-nextgen:latest
```
Same compose file shape as v4.0.15 / v4.0.16 — swap the image, restart.