Repository navigation
fix(logging): stop logging dropped matcher-queue fetches and node relays as errors - #5596
Conversation
…elays as errors The admin matcher-queue and unmatched-items reads and the segment relay to a transcode node (in the API and in the proxy) logged ERROR "context canceled" when the client dropped the request, which fills Admin > Logs with failures that did not happen. Log those at Debug with ctxerr.LogLevel, as the other request paths already do; real failures stay at ERROR and the relay still answers 502. Closes Silo-Server#5562
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
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:
|
…RROR The API relay read a signed manifest with io.ReadAll and logged any read error at ERROR, including a player canceling partway through the body. Use the same ctxerr.LogLevel check as the connect error above it. The 502 answer is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quick104
left a comment
There was a problem hiding this comment.
One finding, in relayToTranscodeNode, the relay function this PR already changes. It sits outside the diff, at internal/api/handlers/playback.go:2762.
Low: an abandoned manifest read still logs at ERROR. When the relay rewrites a signed manifest, it reads the node's body with io.ReadAll. If the player cancels after the node has sent its headers (a seek, a playlist refresh, the app going to the background), the read returns context canceled and this line records read transcode node manifest as an error. That is the same noise #5562 reports, coming from the manifest branch instead of the connect branch the PR converts at line 2730. The proxy's matching body read in internal/proxy/server.go already skips logging once the request context is done.
A scratch test against this head (node sends headers and part of a playlist, then the request context is canceled) logged level=ERROR msg="read transcode node manifest" ... error="context canceled" and answered 502.
Repair: take the level from ctxerr.LogLevel(r.Context(), readErr, slog.LevelError) like the line above, and keep the 502. I'm fixing this in a commit on this branch, so there's no need to change it yourself.
🤖 Claude Code (claude-opus-5-5)
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:
|
/silo review summaryReviewed head: Evidence: https://evidence.siloserver.org/r/silo-server/pr-5596/ The PR does what it says. On a sandbox built from current Addressed
Other feedback
Remaining for maintainersNone. Checks
CouncilRounds: 2, last reviewed
Round 1: Sol and Gemini both found the manifest-read line (fixed); Opus raised the relay-test nit (answered above). Round 2: the fix holds, no new findings. Fit: 9/10 · Readiness: 9/10 — ready Fit: a small correctness fix that keeps Admin > Logs about real failures, using the cancellation check the codebase already uses at many other call sites. Readiness: both reported paths were reproduced on a sandbox built from 🤖 Claude Code (claude-opus-5-5) |
…ays as errors (Silo-Server#5596) The admin matcher-queue and unmatched-items reads and the segment relay to a transcode node (in the API and in the proxy) logged ERROR "context canceled" when the client dropped the request, which fills Admin > Logs with failures that did not happen. Log those at Debug with ctxerr.LogLevel, as the other request paths already do; real failures stay at ERROR and the relay still answers 502. Adapted to this fork: the relay authenticates with the shared JWT secret, so the handler test drops upstream's node keys; captureDefaultLog is a small local helper because the upstream one lived in a test file this fork does not have. Closes Silo-Server#5562 Ported from upstream ae0e763.
Problem
Closes #5562
Related issue: N/A
Validation tasks: none
Other clients: N/A (no client-visible change)
When a client drops a request partway through, two request paths log an ERROR line ending in
context canceled, and Admin > Logs stores it as an error. Nothing failed for the user. The first path is the admin matcher-queue fetch, which the web app cancels when it refetches after a scan. The second is the segment relay to a remote transcode node, which a player drops when it seeks. This change logs those cancellations at Debug, as #2077 and #2956 already do for other request paths. Real failures still log at ERROR.Approach
Each affected log call now takes its level from
ctxerr.LogLevel(ctx, err, slog.LevelError). The level drops to Debug only when the request context was canceled and the error is a cancellation. A deadline, a database outage, or a cancellation joined with a real error still logs at ERROR.Converted sites:
internal/api/handlers/libraries_service.go: the all-libraries queue fetch (failed to list libraries,failed to load queue statuses). Also the per-library queue reads and thecount,listanditeratesteps ofListUnmatchedItems, which the issue's notes list as logging the same lines. The retry and cancel writes keep plain ERROR logging.relayToTranscodeNodeininternal/api/handlers/playback.go(the node request and the signed-manifest read), and the matching relay ininternal/proxy/server.go. Both still answer 502 after a cancellation, because net/http also cancels the context of an HTTP/1.1 client that has only half-closed. Node health and the decision to move a transcode are unchanged.The web app refetches the matcher queue twice for each scan completion, as the issue describes. That is a separate change and is not part of this PR.
Validation
origin/main, then repeated the same steps on this branch with the same database (see Evidence).origin/mainand pass here.go build ./...,gofmt,go mod tidy -diff,go vet ./...,make lint-changed,make lint-router-recovery,make test-go,make verify-local-paths,make verify-size-ratchet,make verify-bidi: pass.Evidence
Local build with one movie library of synthetic files and one local transcode node. Curl clients were aborted mid-request: 60 rounds of 5 parallel matcher-queue fetches with 2 to 6 ms timeouts, 40 rounds each on the per-library queue and unmatched-items reads, and a "seek" that requests far-ahead segments from a transcode on the node and drops each one after 0.3 s.
Before, on
origin/main(5d0006f), error rows in Admin > Logs:After, on this branch, the same steps on the same database: 125 requests recorded as
status_class=abandoned, 0 ERROR lines in the server log, and no error rows in Admin > Logs. Requests that completed normally still answered 200: the matcher queue, the per-library queue, unmatched items, and segments relayed after the seek.Risks
None identified. Only log levels change. Responses, status codes, node health, and the transcode failover path are unchanged.
Checklist
AI Disclosure
scanning unmatched itemline, which reports a row decode error, not a cancellation.Note
Fix matcher-queue fetch and transcode-node relay logs to not use error level for canceled requests
ctxerr.LogLevel, which demotes context-canceled requests while keeping real failures at error level.LibraryHandler.ListMetadataMatchQueues,ListUnmatchedItems,GetMetadataMatchQueuein libraries_service.go,PlaybackHandler.relayToTranscodeNodein playback.go, andproxy.Server.proxyToTranscodeNodein server.go.Macroscope summarized da64c89.