Repository navigation
Description
What happened
When an admin changes an autoscan source's server or configuration while a poll of that source is running, and that poll then fails, the failure is written to the source as if it came from the new setup. The source shows the old server's error, and last_run_at is stamped with the time of the failed poll.
A successful poll in the same situation is handled: AdvanceMarker checks that the source and its connection still match what the poll read, and skips the write when they don't. The failure path has no such check. RecordError runs SET last_error = $2, last_run_at = now() WHERE id = $1 unconditionally (internal/autoscan/repository.go), and both callers in internal/autoscan/service.go reach it: failPoll (plugin call or connection resolve failed) and the transient-resolve branch of consumeSourceChanges.
On main today, the visible result is a stale error on the source row, attributed to the new server, until the next poll replaces it. Once #2080 lands, which clears last_run_at with the marker so the source is polled at the next cycle, the stamp also cancels that early poll. The source then waits out its full interval before its first poll of the new server, and that first poll starts from "now", so imports in between are never reported.
This is most likely when the admin is repointing a source because its server stopped answering: a poll to an unreachable host can sit in a connect timeout long enough to overlap the edit.
Steps to reproduce
Not reproduced live. The interleaving follows from the source:
- Bind a poll source to a Sonarr connection whose server does not answer, so a poll blocks until it times out.
- While a poll of that source is running, change the connection's base URL to a working server (or change the source's connection or
source_config). - The edit clears the source's marker (and, with fix(autoscan): poll at once after a marker reset, and not for a respelled URL #2080,
last_run_at). - The running poll times out and
failPollcallsRecordError.
Expected behavior
A poll that read the source before an edit that reset its marker should not write its outcome to the source, whether it succeeded or failed. docs/admin-api.md already says this for the success path: a poll whose snapshot no longer matches "leaves last_run_at and last_error as they were (so the next cycle polls the new upstream without waiting for the interval)". The failed poll should still be recorded on its own poll event.
Silo version / commit
main at ade836a
Deployment
Other: found by reading the source; affects every deployment type.
Area
Libraries, scanning, and metadata
Clients affected
Web UI (admin autoscan source list).
Relevant logs
No logs available. This was found in code review, not on a running server.
Technical notes
One possible fix is to give RecordError the poll's source snapshot and apply the same check AdvanceMarker uses (the source's marker, connection and source_config, and the connection's upstream read FOR SHARE). When the check fails, skip the source write and keep the event's error. A deterministic DB test can reset the source between the poll's snapshot and RecordError.
The fix should follow #2080, since the delayed first poll only exists once that change clears last_run_at on a reset.
AI harness
Claude Code (T3 Code)
AI tool(s)
Claude Code, gh, go
AI model(s)
claude-opus-5-5; cross-provider review by gpt-6.1-sol
AI involvement
Fully AI-generated during a maintainer-directed review run; not yet verified by a person.
Independent or adversarial review
Found while reviewing #2080 by two independent reviewer passes (claude-opus-5-5 subagents) and a cross-provider pass (gpt-6.1-sol). All three traced the same interleaving through failPoll and RecordError. None ran a database race test.
Confirmations
- I searched open and recently closed issues and pull requests, and this is not already reported
- I reproduced this myself on a real deployment
- Any logs provided are raw apart from marked redactions and are not AI-summarized; if none were available, I said so above
Source: found in review of #2080
Activity
fix(autoscan): don't record a failed poll's error on a source reset d…