Repository navigation
fix(markers): let quota-limited marker sync reach every file - #1830
Conversation
The daily Sync online markers task refreshed due results in file ID order. TheIntroDB's daily quota ends a run early, so every run spent the quota on the same low file IDs and newer episodes were never refreshed. Sync now makes one pass ordered by last fetch, never-fetched files first, so each run continues where the previous one stopped. Cache found markers for 30 days and retry empty results after 14 days, as TheIntroDB asks of clients that sync a library. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 28 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Follow-ups to the quota rotation in #1830, found in review after merge. Sync now reads the ordered list of due files once per run instead of paging a sort key that no index serves. Each page had re-sorted the whole library, and a provider whose cooldown ended mid-run could move files behind the page cursor so the run skipped them. Titles released in the last 30 days or due within a week keep the old 7-day and 1-day cache durations, so a new episode that TheIntroDB does not know yet is retried daily instead of after two weeks. The @population lease records a fetch time only when a pass has confirmed the file's external IDs against every provider, and every completion in a pass is dated from the pass's claim. A metadata refresh that leaves the IDs unchanged no longer keeps a file due until its cache expires, and an edit made during a pass is not hidden. A run waits out a rate limit of up to a minute on every provider, also when one is already active at the start, and ends at a longer one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Problem
Related issue: N/A
Validation tasks: none
With stored online markers, the daily Sync online markers task can stop refreshing part of a library for good. TheIntroDB allows about 1,000 lookups a day per key, so a run on a library of a few thousand episodes ends once the quota runs out. Each run starts again at the lowest file IDs. The same older files therefore use the quota every day, and files with higher IDs, which are usually the newest episodes, are never refreshed. A community report showed this on a library of about 3,000 episodes: new episodes never got markers, although TheIntroDB had data for them.
The cache durations make it worse. Found markers were refetched after 7 days and empty results after 1 day, so on a mid-sized library the due refreshes alone can use the whole daily quota. TheIntroDB's developer recommends keeping found results for a month and retrying 404s after 14 days, which is what their Jellyfin and Emby plugins do.
Approach
Sync now makes one pass ordered by each file's oldest fetch, and files never fetched come first. When the quota stops a run, the next run continues with the files that have waited longest, instead of starting over at the lowest IDs. Candidates are still paged with a keyset cursor, now on
(last fetch, file ID). Files fetched during a run move behind the cursor, and they stay out of the candidate list until their retry time.Found markers are now cached for 30 days, and empty results are retried after 14 days. A newly aired episode that TheIntroDB doesn't have yet can therefore wait up to two weeks before it is retried. An admin refresh for an item still bypasses the cache.
docs/markers-api.mddescribes the new order and durations.Validation
go build ./...,gofmt,go vet ./...,make lint-changed(0 issues),make verify-local-paths: pass.SILO_TEST_DATABASE_URLset: pass.make test-goon macOS: all packages pass exceptTestAdminResourceCapabilitiesAndScopeininternal/apiv2, which fails the same way onmainbecause the host reports resource capabilities as unsupported.Risks
Checklist
AI Disclosure
gh, Go toolchain 1.26.5, PostgreSQL 18 (pgvector image)claude-opus-5-5🤖 Generated with Claude Code
Note
Fix marker sync to rotate through all due files when quota-limited
PopulationService.Syncin population.go to use a cursor-driven loop instead of separate unqueried and refresh passes, so each quota-limited run advances to the next least-recently-fetched file instead of repeating the same ones.PopulationStore.Candidateswith aSyncCursor(fetched timestamp + file ID) in population_store.go. The query orders due files by least recent eligible fetch time, with never-fetched and on-demand files first, and keeps existing library, media identity, cooldown, and lease filters.Candidatesmust use the newSyncCursorsignature (the in-tree test fake is updated).Macroscope summarized 7537f67.