fix(search): sort wanted list ascending so backlog isn't starved - #380
Open
lolimmlost wants to merge 1 commit into
Open
fix(search): sort wanted list ascending so backlog isn't starved#380lolimmlost wants to merge 1 commit into
lolimmlost wants to merge 1 commit into
Conversation
_get_arr_records sent sortKey without sortDirection. The *arr API defaults lastSearchTime to descending, returning most-recently-searched items first and never-searched items (null lastSearchTime) last. _filter_wanted_items slices from the top, so it re-searched the same top N every cycle while never-searched items were never reached. With min_days_between_searches=0 the recent-search guard never evicts anything either, making it total starvation. Request sortDirection=ascending so least-/never-searched items lead, which is what the job intends. Correct at any min_days_between_searches, including 0. Fixes ManiMatter#376 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014qSXBcvcc8YbZKsM9RhcYo
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.
Summary
Fixes #376.
search_missing(andsearch_unmet_cutoff) could permanently re-search the same topMAX_CONCURRENT_SEARCHESitems while items that had never been searched were never reached — logging a normal success line every cycle, so it looked healthy.Root cause
src/utils/wanted_manager.py::_get_arr_recordssentsortKeybut nosortDirection:For
lastSearchTimethe *arr API defaults to descending, so the list comes back most-recently-searched first and never-searched items (lastSearchTime: null) last.search_handler.py::_filter_wanted_itemsthen slices from the top (items[:max_concurrent_searches]), so it re-selects the items it just searched. Withmin_days_between_searches=0the recent-search guard (_filter_recent_searches) never evicts anything either, turning this into total starvation of the backlog.Confirmed against a live Sonarr in the issue thread: same endpoint and
sortKey, onlysortDirectionvaries —ascendingyields the never-searched-first order the code intends.Fix
Request the direction explicitly:
Least-/never-searched items lead, which is what the job intends, and it is correct at any
min_days_between_searchesincluding0.Tests
Adds
tests/utils/test_wanted_manager.py: a regression test assertingsortDirection=ascendingin the request params, plus the empty-records early-return path. Full suite passes locally (pytest).Credit to the original reporter for the diagnosis and live-Sonarr verification in #376.
🤖 Generated with Claude Code