Repository navigation
fix(markers): stop recording abandoned lookups as provider failures - #2067
Conversation
A marker lookup whose caller went away, or whose short read deadline passed, was stored as a failed provider request. The file then sat in failure backoff (1 minute rising to an hour) with no online markers, and a provider answer that had already arrived was thrown away because the settings and identity checks after the fetch ran on the dead context. When the pass context is done, a failed fetch now hands its claim back through the new PopulationStore.Release, which keeps the row's failures, backoff, last error and cached result. A rate-limit answer is still recorded. Answers already fetched are saved on a context detached from the caller, bounded by the pass deadline or a five-second grace, and providers not asked keep their cached answers in that save.
A canceled caller with no deadline of its own left the save with the rest of the 90-second pass. Use the short grace once the caller has gone, and check the released row against the database clock.
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:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The claim-release, short-read, and save-after-cancellation paths show no outstanding issue requiring a change before merge. Pre-merge checks |
|
|
This changes playback-visible marker availability after an abandoned lookup ( Posted via Macroscope — Visible change evidence |
Quick104
left a comment
There was a problem hiding this comment.
Review of c43dad4. Two findings: one I'm fixing in a commit on this branch, and one that needs your call. A summary with validation and readiness follows as a PR comment.
AI disclosure: reviewed with Claude Code (claude-opus-5-5), with Claude subagents and a Codex (gpt-6.1-sol) cross-check, run for a maintainer.
On-demand answers are completed inside the loop and never added to pending, so a pass whose caller left after one provider answered returned the bare file: the response and players got none of it until the next lookup. Return early only when the pass fetched nothing. 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:
|
Review summaryReviewed c43dad4. Head is now 8b68ab0: my fix (7f9d3d6) plus a merge of main. Addressed
Remaining
Other feedback
Validated features
CI on 8b68ab0
Checks
Fit: 8/10 · Readiness: 7/10 — conditional (head 8b68ab0)
AI disclosure: Claude Code (claude-opus-5-5) with Claude subagents and a Codex (gpt-6.1-sol) cross-check, run for a maintainer. |
Releasing a claim that a 5-second read ran out of time on left nothing limiting how often a provider slower than that budget is asked: every detail read, MediaSegments request or download manifest asked it again and cut it off. A pass whose caller has less than markerFetchTimeout left is now a short read. When a short read runs out its deadline waiting for a provider, the claim is still released with no failure counted, and other short reads skip that provider for that file for markerReadHold (one minute), using its cached answer if there is one. A viewer leaving (context.Canceled) sets no hold. Lookups that can wait a provider's full timeout, such as the 10-minute playback lookup, the admin refresh and Sync, ignore the hold, so the playback lookup that usually follows a detail read still asks the provider. The hold is kept in memory per replica, next to the on-demand answer cache and capped the same way. A database hold would also stop the playback lookup, because Claim checks retry_at for it, and on-demand rows ignore retry_at altogether.
Problem
Related issue: N/A
Validation tasks: none (the change reaches #1148 C2 and C3, which have no result yet)
If someone opens a title and leaves before the online marker lookup finishes, Silo records that as a failed provider request. A read that runs out its own 5-second marker budget is recorded the same way. The file then sits in failure backoff (1 minute, doubling to an hour), and opening the title again in that window gets no online markers from that provider. If the provider had already answered, that answer is thrown away as well. This change treats an abandoned lookup as abandoned: no failure, no failure backoff, and an answer that already arrived is saved. A provider too slow for a 5-second read is left alone by those reads for a minute instead, while the playback lookup still asks it.
How it happens in
PopulationService.populate:CanceledorDeadlineExceededstatus.recordFetchFailurestores it asoutcome=error, adds one tofailures, setsretry_atfromfetchRetryand logs "marker provider fetch failed" at WARN.Claimwon't take the row again untilretry_atpasses, andforceonly skips the wait for hit and miss rows.checkIdentityafter the loop run on the cancelled context and fail. Every fresh answer is then completed as an error ("marker settings changed" or "marker storage failed"), so the quota it cost is wasted and the failure count still goes up.On my server,
marker_fetch_statehad 198 error rows whose last error is a cancellation or deadline (171 with no cached result, up to 11 failures on one file) and 14 rows from the two post-fetch errors. The log had 16 "marker provider fetch failed" warnings withcode = Canceledin 26 hours.Approach
PopulationStore.Releaseinstead of completing it. Release clears the lease and leavesoutcome,failures,retry_at,last_errorand the cached result as they were. The one exception is a claim for a new identity:Claimhas already dropped the old result, so Release makes the row due now instead of leaving it behind the old answer'sretry_atwith nothing cached. Nothing is logged for these.context.Canceledorcontext.DeadlineExceeded, so callers can recognise it witherrors.Is.context.Canceled) sets no hold. The 10-minute playback lookup, the admin refresh and Sync ignore the hold, so the playback lookup that usually follows a detail read still asks the provider.marker_fetch_statewould also block the stored-mode playback lookup, becauseClaimchecksretry_atfor it, and on-demand rows ignoreretry_ataltogether.Validation
populationRecorderfake cover a viewer leaving and a read deadline passing mid-request (claim released, no completion, no WARN), a fresh answer saved when the viewer leaves before the settings re-check or the identity check, a cached second provider kept in that save, and a provider's own timeout and a rate limit still being recorded. The first three fail on 6e208ef: the cancelled request is stored asoutcome=error, and the fetched answer is never written.TestPopulationOnDemandAppliesFetchedMarkersAfterViewerLeavescovers on-demand mode: the first provider answers and the viewer leaves while the second is asked. It failed before 7f9d3d6 (no markers returned or sent to players).TestPopulationShortReadsHoldSlowProvidercovers the hold in stored and on-demand mode ontesting/synctestfake time, with a provider that takes 10 seconds. A 5-second read is cut off, a second read inside the minute doesn't ask the provider, a read after the minute does, and a 10-minute lookup during a hold gets the provider's answer. It fails on 8b68ab0, where the second read asks again.TestPopulationViewerLeavingDoesNotHoldProviderchecks that a viewer leaving sets no hold, andTestPopulationHoldsAreCappedchecks the cap. The read-deadline case ofTestPopulationCanceledLookupIsNotAProviderFailurenow reports a 5-second deadline, so it runs as a short read.go test ./internal/markers/...passes,-race -count=3on the population tests passes, andgo vet ./internal/markers/,go build ./cmd/silo/andmake lint-changedare clean. The DB-backed store tests skipped locally because I had no database running for this commit; theReleaseSQL is unchanged, andGo DB pinsruns those tests in CI.TestPopulationStoreReleaseKeepsFetchStatechecks the new SQL against Postgres: the row's state is unchanged, a wrong token leaves the lease alone, and a released new identity is due again. It passes against a local migrated PostgreSQL 18 database with the other population store tests, and fails if theretry_atreset is removed. I added it toscripts/ci/db-contracts.txtsoGo DB pinsruns it.go build ./...,go vet ./internal/markers/andmake lint-changed: clean.Go DB pins, which runs the newReleasetest (run).Go DB pinsandGo lint.Web (build)fails the launch bundle budget, as it does on main ([bug] Web build fails the launch bundle budget on main after #2168 #2203); this PR changes no web code.Go DB pins(which runs theReleasetest),Go lint,Go testandGo integration, and the web tests passed.Web (build)fails the same launch bundle budget check as main ([bug] Web build fails the launch bundle budget on main after #2168 #2203), andCI resultfails only because of it.Benchmarks
Not applicable. This changes what is recorded when a lookup is abandoned, not the cost of a lookup.
Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-2067/
Before: the production counts and log lines above, from a read-only query and the server log. After: the regression tests. Markers show up in players, but nothing renders differently; the change is whether a title has online markers after someone abandoned an earlier lookup.
Risks
Checklist
AI Disclosure
AI-assisted with Claude Opus. I directed the task and designed the work.
Note
Stop recording abandoned marker lookups as provider failures
Caller cancellation or pass expiry during marker population no longer marks the provider as failed. Abandoned claims release through a new
PopulationStore.Releasemethod that clears the lease without changing outcome, failure count, or retry state.firstToExpire(population.go).populatein population.go andReleasein population_store.go.Macroscope summarized 6a6e488.