Skip to content

fix(logging): stop logging dropped matcher-queue fetches and node relays as errors - #5596

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/5562-quiet-cancelled-queue-relay-logs
Nov 30, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/5562-quiet-cancelled-queue-relay-logs

Conversation

@Rhainland

@Rhainland Rhainland commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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 the count, list and iterate steps of ListUnmatchedItems, which the issue's notes list as logging the same lines. The retry and cancel writes keep plain ERROR logging.
  • relayToTranscodeNode in internal/api/handlers/playback.go (the node request and the signed-manifest read), and the matching relay in internal/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

  • Reproduced both paths on a local build of origin/main, then repeated the same steps on this branch with the same database (see Evidence).
  • New tests: an abandoned matcher-queue fetch logs nothing at ERROR while an unreachable database still does, and both relays answer 502 without an ERROR line when the client drops a segment request that reached the node. All failed on origin/main and 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.
  • Not run: the web gate (no web change) and the API contract and fixture checks (no contract change).

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:

error|counting unmatched items|35
error|iterating unmatched items|1
error|metadata queue: failed to list libraries|1
error|metadata queue: failed to list movie queue|9
error|metadata queue: failed to list raw backlog|1
error|metadata queue: failed to list series queue|4
error|metadata queue: failed to load queue status|36
error|metadata queue: failed to load queue statuses|10
error|proxy to transcode node|3
level=ERROR msg="proxy to transcode node" component=api error="Get \"http://<node>/transcode/<id>/segment/seg_00040.ts\": context canceled" ...
level=INFO msg="apiv2 request" component=apiv2 operation_id=getPlaybackSegment ... status=0 status_class=abandoned ... duration_ms=300

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

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code (via T3 Code); Codex CLI for code review
  • Tool(s): Claude Code (Bash, Read, Write, Edit, Agent), GitHub CLI, Codex CLI
  • Model(s): claude-opus-5-5; gpt-6.2-sol (code review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Two independent reviewers (Codex and a fresh Claude Opus agent) reviewed the branch diff for correctness, repository standards, and fit with the issue. No correctness bug was found in the logging change. Fixed: the relay tests could pass without the relay reaching the fake node, so they now assert that it did and no longer leave a goroutine waiting. A re-review of that fix found nothing. Not changed: a request to also test the queue-status branch, which needs Postgres to list libraries first (the local run drove that branch, 10 errors before and 0 after); a note that three tests check one helper, kept because each covers a different call site in a different handler or package; duplicated test setup across two packages that share no test helper; and the scanning unmatched item line, 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

  • Dropped matcher-queue fetches and transcode-node relay/proxy failures are no longer always logged at error level. Log severity is now chosen by ctxerr.LogLevel, which demotes context-canceled requests while keeping real failures at error level.
  • Applies to LibraryHandler.ListMetadataMatchQueues, ListUnmatchedItems, GetMetadataMatchQueue in libraries_service.go, PlaybackHandler.relayToTranscodeNode in playback.go, and proxy.Server.proxyToTranscodeNode in server.go.
  • Adds tests covering canceled contexts and unreachable databases for the queue handlers, plus tests that an abandoned segment still returns HTTP 502 without an error-level log.
  • Behavioral Change: only log severity changes. API responses (including HTTP 502) and returned errors are unchanged.

Macroscope summarized da64c89.

…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
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Metadata queue, unmatched-item, playback relay, and transcode proxy error logs now use context-aware levels. Tests check that canceled requests do not produce error-level logs and that genuine database failures remain logged at error level.

Changes: Cancellation-aware logging

Layer / File(s) Summary
Metadata queue logging
internal/api/handlers/libraries_service.go, internal/api/handlers/libraries_service_test.go
Metadata queue and unmatched-item failure logs now use context-aware levels. The test checks canceled requests and database connection failures.
Transcode relay logging
internal/api/handlers/playback.go, internal/api/handlers/playback_proxy_test.go, internal/proxy/server.go, internal/proxy/segment_completion_test.go
Playback handler and proxy relay failure logs now use context-aware levels. Tests check that canceled segment requests return 502 without an error-level log.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: quick104, blurbery, darthshadow

Merge Risk: Minimal · up to da64c

This change only lowers the log level for requests the client abandoned. Real failures still log at ERROR and responses are unchanged, so no meaningful merge risk remains.

Security architecture risk: Minimal · up to da64c

Canceled requests produce fewer misleading error logs. Genuine failures still log at error level, and request responses and relay behavior are unchanged.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#5562] Requirements: (1) client-abandoned matcher-queue fetches and transcode-node segment relays log at a lower level than ERROR, while real failures stay at ERROR; (2) same handling for per-library… Make the libraries_service.go and playback.go diffs readable at the reviewed head, or provide the hunks for ListMetadataMatchQueues, GetMetadataMatchQueue, ListUnmatchedItems, and relayToTranscodeNode. Confirm each changed call uses ctxerr.…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: cancelled matcher-queue fetches and node relays now log below ERROR. It uses the conventional fix(logging) prefix. It is specific and matches the changeset, which swit…
Out of Scope Changes check Passed The verified change in internal/proxy/server.go adds only the ctxerr import and replaces a fixed ERROR log with ctxerr.LogLevel. It is directly tied to issue #5562. The PR description and summary desc…
Description check Passed The description is related to the changeset. It explains the problem (ERROR logs ending in context canceled for the matcher-queue fetch and the transcode-node segment relay), lists the converted call …
Full details: Title check

Explanation

The title names the main change: cancelled matcher-queue fetches and node relays now log below ERROR. It uses the conventional fix(logging) prefix. It is specific and matches the changeset, which switches the affected log calls to ctxerr.LogLevel.

Full details: Out of Scope Changes check

Explanation

The verified change in internal/proxy/server.go adds only the ctxerr import and replaces a fixed ERROR log with ctxerr.LogLevel. It is directly tied to issue #5562. The PR description and summary describe the other changes (libraries_service.go, playback.go, and test files) as log-level changes on the same request paths. The summary says a later commit also applies context-aware logging to a signed-manifest read in playback.go. That read is on the transcode-node relay path named in #5562, so it has a clear connection to the issue. The PR description does not mention it, so the author should confirm it is intended. The web-app duplicate refetch is explicitly excluded and is not in the diff.

Full details: Description check

Explanation

The description is related to the changeset. It explains the problem (ERROR logs ending in context canceled for the matcher-queue fetch and the transcode-node segment relay), lists the converted call sites in libraries_service.go, playback.go and proxy/server.go, and describes the validation and tests. Level of detail is not a factor for this check.

Full details: Linked Issues check

Explanation

[#5562] Requirements: (1) client-abandoned matcher-queue fetches and transcode-node segment relays log at a lower level than ERROR, while real failures stay at ERROR; (2) same handling for per-library queue and unmatched-items paths; (3) relay keeps its 502 response; (4) node health is not affected. Verified at the reviewed head: internal/proxy/server.go proxyToTranscodeNode now logs with slog.Log(r.Context(), ctxerr.LogLevel(r.Context(), err, slog.LevelError), ...), and the 502 response and the rest of the path are unchanged. Not verified: the diff for internal/api/handlers/libraries_service.go could not be read (changed blobs unavailable in the checkout). The per-library queue, unmatched-items, and all-libraries queue log changes rest only on the PR description and the AI-generated summary (nine call sites changed, +9/-9). The internal/api/handlers/playback.go relay change is also supported only by the summary. The added tests were not read. Requirements (2) and the handler part of (1) therefore lack source evidence.

Resolution

Make the libraries_service.go and playback.go diffs readable at the reviewed head, or provide the hunks for ListMetadataMatchQueues, GetMetadataMatchQueue, ListUnmatchedItems, and relayToTranscodeNode. Confirm each changed call uses ctxerr.LogLevel with slog.LevelError as the fallback and that the retry and cancel writes stay at ERROR. Confirm the new tests in libraries_service_test.go, playback_proxy_test.go, and segment_completion_test.go exist and assert the no-ERROR behavior.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a800ca53-df57-4111-9eeb-ad098647db58
Commits

Reviewing files that changed from the base of the PR and between 5d0006f and da64c89.

Files selected for processing: 6

  • internal/api/handlers/libraries_service.go
  • internal/api/handlers/libraries_service_test.go
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_proxy_test.go
  • internal/proxy/segment_completion_test.go
  • internal/proxy/server.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@silo-kody

silo-kody Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 29, 2026
@silo-triage silo-triage Bot added bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Nov 29, 2026
…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 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

silo-kody Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Copy link
Copy Markdown
Contributor

/silo review summary

Reviewed head: da64c898a3 (the contributor's 71052f7e plus one fix commit).

Evidence: https://evidence.siloserver.org/r/silo-server/pr-5596/

The PR does what it says. On a sandbox built from current main, aborted matcher-queue and unmatched-items reads wrote ERROR rows ending in context canceled to Admin > Logs; on the same sandbox rebuilt with this branch merged onto that main, the same steps wrote none. The same held for a seek on a remote transcode: 30 segment requests dropped after 0.3 s through the proxy node left 30 proxy to transcode node ERROR rows on main and none on this branch, while normal segment requests still answered 200. The three new tests fail on the base for the reported reason and pass on the head under -race -count=3.

Addressed

  • An abandoned manifest read in the API relay still logged at ERROR (internal/api/handlers/playback.go, the read transcode node manifest line in relayToTranscodeNode). Fixed in da64c89 with the same ctxerr.LogLevel check as the connect error above it; the 502 is unchanged. A scratch test that cancels the request after the node sends part of a playlist logged ERROR before the fix and nothing at ERROR after it. I didn't commit that test, since the PR already covers each relay with one.

Other feedback

  • Kody's suggestion to answer 404 instead of 502 on a canceled relay was withdrawn in its thread; the 502 predates this PR and is out of scope.
  • A council member noted that the relay tests assert only that no ERROR line appears, not that a real relay failure still logs one. Left as is: the matcher-queue test covers the real-failure branch of the same helper, and the relay's real-failure path is unchanged code.

Remaining for maintainers

None.

Checks

  • Contract: no change. Status codes, problem types, response bodies, and the relay's 502 are the same on /api/v2 and on the Jellyfin-compatible surface. The Jellyfin-compatible relays don't log these errors, so they need no matching change.
  • Validated features: no passed case on the v1.0 board is affected. The remote-transcode failover and seek cases share the relay code, but only a log level changes there. Validation tasks: none is correct.
  • User manual: unaffected.
  • Other clients: N/A, server log levels only.
  • Branch: merges cleanly with current main; the base changes since the merge base don't touch these functions.

Council

Rounds: 2, last reviewed da64c898a3

Member Round 1 (71052f7e) Round 2 (da64c898a3)
Sol (gpt-6.2-sol, medium) 9/10 9/10
Opus (claude-opus-5-5, medium) 9/10 9/10
Gemini (gemini-4-neon, medium) 9/10 10/10

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 main and shown gone on one built from this branch, the new tests fail on the base, and the validation-board check ran.

🤖 Claude Code (claude-opus-5-5)

@Quick104
Quick104 merged commit ae0e763 into Silo-Server:main Nov 30, 2026
18 checks passed
randrini added a commit to kipsilabs/Vio that referenced this pull request Dec 1, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority. triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Abandoned matcher-queue fetches and transcode-node segment relays still log ERROR "context canceled"

2 participants