Repository navigation
fix: give Prowlarr searches a 180 s timeout and pace the nightly retry sweep - #608
Merged
Merged
Conversation
…y sweep A Prowlarr search now has its own 180 s timeout, set per request on the /search GET that every automatic and interactive search goes through. /indexer, /health, /indexerstats, RSS, .torrent fetches and the download clients keep 60 s. The nightly retry sweep queued up to 50 searches at once, and Bull runs about 28 jobs of the queue together. It now queues each search with a Bull delay of floor(n / 2) x 60 s, audiobook and ebook on one schedule, so at most 2 start a minute. addSearchJob and addSearchEbookJob take an optional delay; other callers add none. Pacing lets a queued search wait up to about 25 minutes, so the ebook search job's first write now uses the stop guard and skips a cancelled or deleted request, as the audiobook search already does. Thanks to joeg-git for the timing measurements. Closes #601 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A paced ebook search can wait in the queue for up to about 25 minutes while the RSS monitor, fetch-ebook or Manual Search starts another search and a download. Like the audiobook search job, the ebook job's searching write now refuses a request that is cancelled, deleted or in SEARCH_JOB_REFUSED_STATUSES and skips with success, so it adds no second download record or download. Its no-result awaiting_search write uses the same condition, so a download or cancel during the search is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A delayed ebook search could claim a request while another search on it was still running. When that other search started a download first, this job still created a second download record and queued a second download, and a throw after the request moved on wrote failed over it. Both download hand-offs (Anna's Archive and indexer) now start with the same empty conditional write the audiobook search uses before its grab; a request cancelled, deleted or past searching returns success with "no download queued" and nothing is written or queued. The failed write in the catch uses the same condition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
PROWLARR_SEARCH_TIMEOUT, next to the existingDOWNLOAD_CLIENT_TIMEOUT). It is set per request on the/searchGET inProwlarrService.search(), which every search goes through: the automatic audiobook and ebook search jobs and Interactive Search (audiobook and ebook, from a request or from a book page before a request exists)./indexer,/health,/indexerstats, RSS, .torrent fetches and the download clients keep 60 s.floor(n / 2) x 60 sfor the nth search it queues, audiobook and ebook on one schedule: at most 2 start a minute, and 50 spread over about 25 minutes.addSearchJobandaddSearchEbookJobtake an optionaldelay; every other caller adds none, so their searches start as before. No new setting, no change to queue concurrency.searchingwithout checking the request first. Pacing widens the time a queued search waits from seconds to up to about 25 minutes, and meanwhile the RSS monitor, fetch-ebook or Manual Search can start another search and a download. So the guard is part of this fix: like the audiobook search job, the ebook job'ssearchingwrite now refuses a request that is cancelled, deleted, or alreadydownloading,processing,downloaded,available,awaiting_approvalordenied(SEARCH_JOB_REFUSED_STATUSES), and skips with success ("Request is downloading, search skipped"): no second download record, no second download. Its no-resultawaiting_searchwrite, an empty re-check just before each download hand-off (Anna's Archive and indexer) and its failure write use the same condition, so a download or cancel that lands during the search is not overwritten and no second download is queued. Every caller queues the job frompending,failed,awaiting_searchorawaiting_release, so they are unaffected.pendingwith the time it was queued; it turnsactivewhen it starts. Cancelling the job there removes the delayed Bull job as before.jobs.md,prowlarr.md(the old "30s per search" line was stale),scheduler.md,ebook-sidecar.md.Why
The search shared the 60 s ceiling sized for .torrent fetches, and the sweep burst made slow indexers slower still. Thanks to joeg-git for the measurements in the issue: with 8 indexers, 8 of 20 searches went past 60 s, 210 "timeout of 60000ms exceeded" errors over 72 hours touched 101 of 140 waiting requests, and 180 s ran for months without a false abort.
Checks
delayonly when set); the search GET carries 180 s whilegetIndexersand RSS keep 60 s; a cancelled request's ebook search writes nothing and searches nothing; a delayed ebook search for a request nowdownloadingoravailableleaves the row alone and queues no download, while apendingone still searches; a download that starts during an ebook search that finds nothing keeps its status; a download that starts during an ebook search that finds a result (Anna's Archive or indexer) keeps its status and gets no second download record or download job, while apendingrequest still hands off once; a search that throws after a download started leaves the rowdownloading.npx vitest related --runpassed on each commit (on the last one: 157 files, 1959 tests).npx tsc --noEmitclean. eslint: no new findings on the changed files.Risk and rollback
searchWithVariationsruns at least 2 queries in sequence.Closes #601
🤖 Generated with Claude Code