What's new
docker pull ghcr.io/new-usemame/calibre-web-nextgen:v4.0.66
(or :latest)
Fix: the underlying cause behind ingest-time 504s
v4.0.65 raised the default After import debounce from 5 → 30 seconds to make the duplicate-scan deadlock from CWA #1256 less frequent. This release eliminates the deadlock pattern at its source.
What was happening: the web server shares one SQLite connection across all threads. Several request handlers — tag autocomplete, edit-book pages, admin config save, "mark as read" — were re-registering the same Python helper functions on that shared connection every time they ran. When a background duplicate scan was mid-query on the same connection, the two threads could block each other on the SQLite mutex and the Python interpreter lock at the same time. The web UI went silent until something killed the worker.
The fix moves that one-time setup out of every request and into the database connection's open phase, so it happens exactly once when the connection is created. After this release, no production code path can trigger the collision under any load profile, library size, or debounce setting.
What changes for you: nothing visible. Pages keep working the same way. The 504s on large libraries during ingest go away.
Architectural credits
@navels identified the underlying GIL+SQLite collision pattern in CWA #1256. @kanjieater filed the original CWA issue and provided the reproduction trace that surfaced the post-v4.0.65 residual risk.
Verification
29 new regression tests pin every request handler, hot path, and the engine-listener wire-up. Live container test: 50 concurrent tag-autocomplete requests during an active duplicate scan all return HTTP 200 in 1 second, with no "database is locked", no "no such function", no traceback in the logs.
Architectural follow-ups
@navels's open CWA PRs #1349 (defer post-import work until batch settles) and #1353 (incremental duplicate index — full schema rework) remain candidates for backport in follow-up cycles. The deadlock fix in this release is independent of either and complements both.