Skip to content

fix(library): back off after a failed index instead of retrying for every result - #1430

Open
splitsec2 wants to merge 1 commit into
calibrain:mainfrom
splitsec2:fix/calibre-index-backoff
Open

splitsec2 wants to merge 1 commit into
calibrain:mainfrom
splitsec2:fix/calibre-index-backoff

Conversation

@splitsec2

@splitsec2 splitsec2 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Kept small on purpose so it's easy to review.

library_index._entries_for retries fetch_entries on every call while the index is failing. The lookup runs once per search result, so with the Calibre path unreadable a page of 40 results makes 40 attempts and logs 40 warnings. The entrypoint runs one gevent worker and the Calibre read is synchronous sqlite, so each attempt also holds up every other request.

After a failure it now answers from the stale cache (or an empty list) for 60 seconds before trying again, and a successful index clears that. The new tests cover 40 lookups against a failing library with a stale cache (one failed attempt, one warning), a failing library with no cache (tried once), and a retry once the 60 seconds have passed. The first and second fail on current main.

I left a few other things in this module out to keep this one small: re-indexing blocks the worker for as long as a big library takes (I haven't measured how long), test_connection stores entries from the unsaved form path under the shared cache key, and a title with a collection word in it, like "Books of Blood", shows as "In a collection". I can send any of those separately.

Ruff and basedpyright are clean and tests/core passes.

The one red check is the existing clock-dependent test test_a_queued_torrent_asks_for_a_grace_once, which fails on any runner that booted recently. It is fixed in #1426 and is not caused by this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant