Repository navigation
Conversation
…h scans it Complete Refresh clears its scope's content links and scans the scope, whose ingest matches the series root through the TV match queue. The scan re-queues the root, but the upsert keeps a later available_at, so a root an earlier failure backed off (a hand-matched folder no provider finds on its own, at no_candidates) was not claimed. The refresh waited out its relink window and failed, and the folder was in neither the library nor Unmatched Items until the back-off ended or an admin pressed Retry now. SeriesRootMatchQueueRepository.WakeInScope returns the backed-off rows of every series root in a scope to pending, as WakeRoot does for one root: roots at or under the scope, and roots with a present file in it. A complete refresh of a series, season or episode calls it after clearing the links and before its scan; a failed wake fails the refresh before the scan. The new DB test is listed in scripts/ci/db-contracts.txt. Closes Silo-Server#5337 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| if isSeriesTarget(req.RequestedType) && e.seriesRoots != nil { | ||
| if err := e.seriesRoots.WakeInScope(ctx, req.ScanFolderID, req.ScanPath); err != nil { | ||
| return nil, fmt.Errorf("prepare complete refresh: %w", err) | ||
| } |
There was a problem hiding this comment.
Wake failures leave the refresh scope unlinked without scanning
A queue error after prepareCompleteRefresh commits claim and file-content link removal leaves the series absent without a restoring scan. Wake the queue before destructive preparation, or make preparation and wake atomic.
Prompt for LLM
File internal/adminjob/item_refresh.go, lines 667-670:
Wake failures leave the refresh scope unlinked without scanning
A queue error returns after `prepareCompleteRefresh` has already deleted claims and committed the removal of file content links, leaving the series absent without running the scan that restores it. Wake the queue before destructive preparation, or make the preparation and wake atomic.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Fixed in 6b3b60e. The wake now runs before prepareCompleteRefresh, so a failed wake returns with the claims and links untouched. TestItemRefreshExecutorCompleteRefreshFailsWhenTheWakeFails now checks that no links were cleared and no scan ran.
There was a problem hiding this comment.
That addresses the reported failure path: if the wake fails before prepareCompleteRefresh, the existing claims and links remain intact, and the added assertions check that neither link clearing nor scanning occurs.
I haven’t independently verified commit 6b3b60eac.
| UPDATE series_root_match_queue q | ||
| SET state = 'pending', | ||
| available_at = CASE WHEN q.lease_token = '' THEN NOW() ELSE q.available_at END, | ||
| deterministic_attempt_count = 0, | ||
| failure_kind = '', failure_detail = '{}'::jsonb, last_error = '', parked_at = NULL, |
There was a problem hiding this comment.
A leased worker can undo the wake by restoring backoff
A leased worker's UpdateFailure can restore the one-hour backoff, preventing the refresh scan from reclaiming the root and leaving cleared files unlinked. Set rerun_requested for leased rows so completion or failure schedules a fresh match.
Prompt for LLM
File internal/metadata/series_root_match_queue_repo.go, lines 820-824:
A leased worker can undo the wake by restoring backoff
When a worker already holds the row, its subsequent `UpdateFailure` can restore the one-hour backoff because the wake does not set `rerun_requested`, so the refresh scan cannot claim the root and the cleared files remain unlinked. Request a rerun for leased rows so the worker's completion or failure schedules a fresh match.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Fixed in 6b3b60e. WakeInScope sets rerun_requested on a leased row and keeps its available_at. The worker's UpdateFailure (or Delete) then makes it due at once instead of restoring the back-off. New DB test TestSeriesRootQueueWakeInScopeRerunsALeasedRowDB covers it and is listed in scripts/ci/db-contracts.txt.
There was a problem hiding this comment.
Thanks for addressing the race. Setting rerun_requested on leased rows should prevent a worker’s completion or failure from restoring the backoff, and the new DB test covers that case. I haven’t independently verified the commit or test results.
Review follow-ups: - Wake the scope's series roots before prepareCompleteRefresh clears its links, so a failed wake leaves the series as it was instead of returning with the links already cleared and no scan to restore them. - A row a worker holds while the refresh wakes it is asked to rerun, so the worker's UpdateFailure or Delete makes it due at once instead of restoring its back-off. - Move the waker, its setter and isSeriesTarget to item_refresh_wake.go, keeping item_refresh.go under its 1,000-line size limit. The leased-row DB test is listed in scripts/ci/db-contracts.txt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Depends on: none. Merge order: none.
Problem
Closes #5337
Related issue: #934
Validation tasks: #1250 (C2), #1251 (C2), where the issue was found
Other clients: none. This is the server's Complete Refresh job, started from web admin.
Running Complete Refresh on a series an admin matched by hand, from a folder no provider matches on its own, removed it from the library and from Unmatched Items. The folder came back only when its match back-off ended (an hour, then a day, then parked) or after Retry now in the Metadata Matcher.
prepareCompleteRefreshclears the scope's content links, and the refresh's scan (IngestUnlinkedSubtree) matches the series root through the TV match queue: it re-queues the root and claims it withClaimByFolderAndPathPrefix. That claim takes only a row whoseavailable_athas passed, and the re-queue's upsert keeps the lateravailable_at(GREATEST(...)inEnqueueSeriesRoot). A root an earlier failure had backed off asno_candidatestherefore wasn't claimed. With nothing rebuilt, the job failed witherrNoRebuiltContentafter its 60 s relink wait, and the next scan removed the empty series.Approach
The issue's expected behavior allows either rebuilding the series or returning the folder to Unmatched Items right away. This takes the second, which matches what Retry now does today, and does not try to carry the hand match through the refresh.
SeriesRootMatchQueueRepository.WakeInScope(folderID, scopePath). It returns to pending the parked or backed-off row of every series root in the scope, the same resetWakeRootmakes for one root. That covers roots at or under the scope, and roots with a present file in it, so a season or episode refresh wakes its series root.WakeRoot, it requests no rerun of an idle row. A row a worker holds keeps itsavailable_atand getsrerun_requested, so the worker'sUpdateFailureorDeletemakes it due at once instead of restoring a back-off.ItemRefreshExecutorgets an optionalSetSeriesRootWaker, wired incmd/silo/main.goto the series root queue repository. A complete refresh of a series, season or episode calls it before it clears the links and scans. The scan's re-queue then puts the row in the quiet window thatIngestUnlinkedSubtreealready waits out, and the scoped match claims it.isSeriesTargetlive initem_refresh_wake.go, keepingitem_refresh.gounder its 1,000-line size limit.Validation
TestSeriesRootQueueWakeInScopeDB, over three backed-off roots:ClaimByFolderAndPathPrefixfor the season folder claims nothing while the root is backed off, and claims the root once it is woken. This is the step the refresh missed.TestSeriesRootQueueWakeInScopeRerunsALeasedRowDB: a leased row keeps itsavailable_atand gets a rerun, and the worker'sUpdateFailurethen leaves it due.scripts/ci/db-contracts.txt, andgo run ./scripts/ci/dbpins -shared -listpasses them.TestItemRefreshExecutorCompleteRefreshWakesBackedOffSeriesRoot:TestItemRefreshExecutorCompleteRefreshFailsWhenTheWakeFails: a wake error fails the refresh with no links cleared and no scan.main; the claim subtest shows the bug against the unchanged claim.go test ./internal/adminjob/: pass.go test ./internal/metadata/: pass, apart fromTestArtworkRevisionGCRunLocksBatchDuringDeletion, which in a full run on my shared local database sees artwork rows other tests left. It passes when run alone, on this branch and onmain.go vet: clean.golangci-lint run --new-from-rev=origin/mainon the three packages: 0 issues.Evidence
Evidence: not needed. The change is when the server's TV match queue claims a root. Its user-visible result, the folder staying in Unmatched Items, follows from the claim the DB test shows.
Risks
Checklist
AI Disclosure
🤖 Generated with Claude Code