Skip to content

fix(playback): move a transcode off a node that hangs - #2579

Merged
Quick104 merged 14 commits into
Silo-Server:mainfrom
Rhainland:fix/2296-hung-node-failover
Oct 21, 2026
Merged

Quick104 merged 14 commits into
Silo-Server:mainfrom
Rhainland:fix/2296-hung-node-failover

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2296
Related issue: #1176
Validation tasks: changes #1177 C3, #1178 C2, #1252 C5, Silo-Server/silo-apple#337 C5 (hung transcode nodes only)

These cases change only for a transcode node that hangs. #1177 C3 passed for killed and refusing workers and left hangs to #2296; the web (#1252 C5) and iOS (silo-apple#337 C5) reconnect results covered network drops, not a hung worker. With this change an API-relayed transcode moves to another executor on the server, and with proxy egress the proxy answers 502 so the client's existing reconnect and replan path takes over instead of waiting out its request timeouts. Killed, refusing, and slow-but-live nodes behave as before. #1178 C2 passed on bfd02acf6 for a killed worker but did not exercise a hung one; with this change, what Admin > Activity shows for a session on a hung node changes because the session now moves or replans. Each case needs a re-test with a hung node after merge.

When a transcode node hangs mid-stream, native playback stalls until the player's own timeouts run out, about 3 minutes in the web player. A hang means the node's process stops answering while its host still accepts connections: a stopped or deadlocked process, for example. A node that crashes or loses its host already fails over within seconds, because its connections are refused or time out. A hung node gives no such signal: every segment request is accepted and then waits forever, through the API relay and through a proxy alike. With this change the server finds a hung node within about 6 seconds of the first request that waits on it. It then moves an API-relayed transcode to another executor, the way #1956 does for a dead node, and a proxy answers 502 so the client replans.

Approach

A fixed response timeout can't tell a hung node from one that is slowly rebuilding a transcode, which can legitimately take over a minute. So a call that has waited 2 seconds for response headers asks the node directly: it probes the node's unauthenticated /api/v1/health endpoint, and probes again every 3 seconds while the call keeps waiting. A live node answers health at once however slow the call is, so the call keeps waiting. An unanswered probe (2-second bound) is retried at once. A node that misses both probes is treated as unreachable: the call is canceled with nodepool.ErrNodeNotAnswering, which nodepool.IsConnectFailure counts like a refused connection.

  • The check is transcodeproxy.DoNode. It wraps the native API relay, the native transcode start, and the proxy relay.
  • On the API, the existing fix(playback): stop waiting on a dead transcode node #2342 and fix(playback): move a transcode off a dead node instead of failing every segment #1956 paths take over. The node is marked unreachable, peers are told, rechecks restore it once it answers, and the relay moves the transcode. A move into a node that is also hung fails over to the next candidate.
  • Concurrent calls to one node share one probe. A node found hung is remembered in that process until it answers again. Later calls to it probe at once and accept one miss, so its other sessions move within about 2 seconds.
  • A probe this host couldn't send (failed or stalled name lookup, local socket exhaustion) counts as neither an answer nor a miss. These are the same errors that never mark a node.
  • With proxy egress, the client's replan already probes the session's nodes (fix(playback): replan around a transcode or proxy node that stopped answering #2292) and leaves the hung node out.
  • A moved transport keeps its transport id, so a hung node that resumes could delete the new node's recipe card on a late stop. A node now keeps a card whose row id and URL both name another node, judged by the identity it had when it registered the job, and reads and deletes in one Redis transaction. A move skips the dead node's row.

docs/architecture/node-failure-detection.md and docs/architecture/restart-resilient-playback.md describe the rule. No client or API contract change. The server doesn't push plan_invalidated to sessions on a hung node, because each session finds out on its next segment request.

Overlap: #2350 rewrites proxyToTranscodeNode, and its relay closure gets a one-line conflict here. The resolution calls transcodeproxy.DoNode(s.httpClient, req, nodeURL, "stream") inside the closure. Once both land, the Jellyfin relays can use DoNode, and #2350's NodeUnreachable can count ErrNodeNotAnswering, so Jellyfin clients move off hung nodes too. #2355 merges without new conflicts.

Validation

  • New end-to-end tests run a playback session over real HTTP against fake transcode nodes, using production timings. One node serves three segments and then freezes like a stopped process. The next segment is served by the healthy node in about 5 seconds, from segment 3 with continuous numbering. The frozen node is marked unhealthy and receives the stop for its transport, and the next segment needs no second start. With worker_only and no other node, the relay answers 502 within the same bound. A slow node that keeps answering health is waited on, and nothing moves. The proxy answers 502 for a hung node. A replan's probe leaves a hung node out.
  • Unit tests cover the probe rules: a hung node, a slow live node, a caller that gives up (not counted as a hang), one lost probe, a remembered node (one shared probe, no grace), a node that recovers, an unresolvable name or a stalled lookup (inconclusive), and a stop marker that can't be read around a moved-card write. They pass repeatedly under -race.
  • On main, the two hung-node tests hit the client's 45-second limit with no answer.
  • Gate: go build, gofmt, go vet, make lint-changed, the apiv2 artifact test, and the playback-fixture, route, migration, scenario, offline-route, apiv2, local-path and case-collision checks pass. make test-go failed only in tests that fail the same way on main on the test host: two DV-strip tests in internal/jellycompat that depend on the host's FFmpeg, and TestHandleStartPlaybackV3DoesNotWaitForSessionSync, a one-second timing test, under load. Every package this change touches passes. These checks did not run because their tools aren't installed: actionlint, ShellCheck, and the web half of verify-settings-bindings-all. No workflows, scripts, or settings changed. The web gate was not run, because no web files changed.

Evidence

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

Recordings of the web player (Chrome, desktop) on a local stack, base c78d23391 against this branch at 980abf766 (the same code is 1d620624c after a rebase onto main), same media and settings. The transcode node is stopped with SIGSTOP mid-playback, then the player seeks past its buffer:

Route Base build This PR
API relay resumes after 194 s resumes after 7.5 s, no reconnect
Proxy egress resumes after 193 s proxy answers 502 within 6 s; player shows Reconnecting, replans, resumes after 25 s

In the proxy case, the time after the first 502 is the web player's existing retry and replan cadence. The change has no layout effect, so mobile web was not captured separately. The iOS client was not recorded here; silo-apple#337 C5 re-validation covers it.

Risks

  • A live node that doesn't answer two health probes within 2 seconds each loses its sessions to other executors, and new work until it answers a recheck. For example, a node too overloaded to serve HTTP.
  • The watch ends when headers arrive. A node that hangs partway through a segment body leaves that response stalled until the client gives up, and the client's retry then triggers the watch.
  • Jellyfin-compatible relays and other node calls (capability reads, stops, completion acknowledgements) don't use the watch yet.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (running in T3 Code)
  • Tool(s): Claude Code, Codex CLI, GitHub CLI
  • Model(s): claude-opus-5-5, gpt-6.1-sol
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: two independent reviews of the branch diff (claude-opus-5-5 and gpt-6.1-sol), then a second gpt-6.1-sol pass over the fixes. Both first-round reviewers found ways a live node could be called hung: a probe failure caused by this host counted against the node, and a single lost probe packet was enough. Both are fixed: local failures are inconclusive, and an unanswered probe is retried. The second pass found that a recovered node kept the one-miss rule; fixed.

Note

Move a hung transcode node's stream to a healthy node via liveness probes

  • Adds transcodeproxy.DoNode, which watches a transcode node while a request waits for response headers. It runs health probes after a grace period and fails the call with nodepool.ErrNodeNotAnswering after two unanswered probes (one for a node already marked hung). See liveness.go.
  • The playback relay and proxy now treat this error as an unreachable transcode node, so a hung node triggers rehome to another node instead of a generic request failure. Rehome selection skips candidates that share the dead node's database row. See playback_transcode_rehome.go and server.go.
  • Recipe teardown now uses noderecipe.Store.DeleteUnlessMoved, which keeps a recipe card when the card names another node by row ID and URL. Transcode nodes record the identity each session started under and judge recipe ownership by that. See store.go and server.go.
  • Moved-transport recipe writes check the shared stop marker before and after the write, using the new StreamDeny.Lookup that reads Redis directly with a timeout.
  • Risk: transcodenode.recipeStore replaces Delete with DeleteUnlessMoved; any out-of-tree implementation of this interface breaks. A slow node that still answers health probes is never classified as hung, so stalled response bodies after headers remain a known gap.

Macroscope summarized 8f10704.

@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Oct 16, 2026
@silo-kody

silo-kody Bot commented Oct 16, 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 bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P1 Core-path bug; painful workaround — next after P0 labels Oct 16, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 16, 2026

Copy link
Copy Markdown
  • Native playback now fails over from a hung node and resumes on another executor (internal/api/handlers/playback.go); the GET log excerpt shows a server response, not the client-visible recovery. Please add a short recording showing the stall-to-resume timing, and identify the client/surface and build or commit.
  • Proxy playback now returns 502 and prompts the client to replan away from a hung node (internal/proxy/server.go); the evidence does not show that client-visible flow. Please add a short recording of the replan, and identify the client/surface and build or commit.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c20da880-4774-4400-83f6-12c3b98ce31b
📥 Commits

Reviewing files that changed from the base of the PR and between 3106604 and 8f10704.

📒 Files selected for processing: 15
  • docs/architecture/restart-resilient-playback.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_hung_node_test.go
  • internal/api/handlers/playback_transcode_rehome.go
  • internal/api/handlers/playback_transcode_rehome_test.go
  • internal/noderecipe/store.go
  • internal/noderecipe/store_test.go
  • internal/playback/recipecard.go
  • internal/playback/recipecard_test.go
  • internal/playback/streamdeny.go
  • internal/playback/streamdeny_test.go
  • internal/transcodenode/server.go
  • internal/transcodenode/server_test.go
  • internal/transcodeproxy/liveness.go
  • internal/transcodeproxy/liveness_test.go

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

📝 Walkthrough

Transcode requests now probe node health while waiting for response headers. Playback and proxy requests use this liveness check to handle unresponsive nodes. Recipe cleanup also checks executor identity so teardown can preserve cards moved to another node.

Changes: Transcode liveness and playback recovery

Layer / File(s) Summary
Detect and classify hung nodes
internal/transcodeproxy/*, internal/nodepool/unreachable.go, docs/architecture/node-failure-detection.md
DoNode probes node health while waiting for response headers and returns ErrNodeNotAnswering when the node misses the required probes. Probe results are shared across callers. Tests cover probe retries, caller cancellation, recovery, and inconclusive local failures.
Use liveness checks in playback and proxy requests
internal/api/handlers/playback.go, internal/api/handlers/playback_transport.go, internal/api/handlers/playback_v3_route_nodes_test.go, internal/api/handlers/playback_hung_node_test.go, internal/proxy/server.go, internal/proxy/segment_completion_test.go
Playback relay, transcode-start, and proxy relay requests use DoNode. Tests cover failover from a hung node, prompt 502 responses when no replacement is available, and waiting for a slow responsive node.
Classify failures and guard recipe writes
internal/api/handlers/playback_transcode_rehome.go, internal/api/handlers/playback_transcode_rehome_test.go, internal/playback/streamdeny.go, internal/playback/streamdeny_test.go, docs/architecture/restart-resilient-playback.md
Playback classifies ErrNodeNotAnswering as unreachable and excludes a replacement with the prior execution row ID. Recipe writes check the session-deny marker before and after writing. Tests cover marker read failures and a stop during a write.
Preserve recipe cards moved to another node
internal/playback/recipecard.go, internal/playback/recipecard_test.go, internal/noderecipe/store.go, internal/noderecipe/store_test.go, internal/transcodenode/server.go, internal/transcodenode/server_test.go, docs/architecture/restart-resilient-playback.md
Recipe deletion checks executor ownership and removes recipe sidecars when deleting. Transcode session teardown records executor identity and preserves cards identified as belonging to another node. Tests cover conditional deletion and stop or reload teardown.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant PlaybackRelay
  participant DoNode
  participant TranscodeNode
  PlaybackRelay->>DoNode: Send transcode request
  DoNode->>TranscodeNode: Forward request
  DoNode->>TranscodeNode: Probe health while waiting for response headers
  TranscodeNode-->>DoNode: Return response or no response
  DoNode-->>PlaybackRelay: Return response or ErrNodeNotAnswering
Loading

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to 8f107

This change moves playback off transcode nodes that stop responding within a few seconds. It also keeps recipe cards that were moved to another node from being deleted during teardown. This review found no open defects. Earlier concerns about recipe deletion races, stale hung-node markers, and DNS stalls have reported fixes. The change appears ready to merge once normal checks pass.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 64.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 21 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: moving playback off a transcode node that hangs.
Description check Passed The description directly explains the hung-node problem, liveness-probe approach, failover behavior, validation, risks, and known limitations.
Linked Issues check Passed Issue #2296 requires playback failover when a transcode node accepts connections but stops answering, without breaking legitimate slow waits. transcodeproxy.DoNode waits 2 seconds for headers, probe…
Out of Scope Changes check Passed The changes stay within issue #2296. Liveness probing, unreachable-node classification, API rehome behavior, proxy failure behavior, recipe-card fencing, stop-marker checks, documentation, and tests s…
Full details: Linked Issues check

Explanation

Issue #2296 requires playback failover when a transcode node accepts connections but stops answering, without breaking legitimate slow waits. transcodeproxy.DoNode waits 2 seconds for headers, probes /api/v1/health, retries one unanswered probe, and returns nodepool.ErrNodeNotAnswering after the required misses. The API relay and transport-start paths use this helper. The API rehome path treats the error as node unreachability, and the proxy path uses it so the client receives 502 and can replan. Tests cover hung nodes, slow live nodes, probe edge cases, API rehome, and proxy failure.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2296. Liveness probing, unreachable-node classification, API rehome behavior, proxy failure behavior, recipe-card fencing, stop-marker checks, documentation, and tests support recovery from a hung transcode node or prevent stale cleanup after that recovery. No unrelated product behavior or client contract change is shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 64.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 21 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@macroscopeapp

macroscopeapp Bot commented Oct 16, 2026

Copy link
Copy Markdown

The recorded playback-recovery cases need re-validation for hung-worker behavior; the current Validation tasks: line omits two affected client cases.

These are major changes: the PR must explain why validated behavior changes, and each case needs re-validation after merge.

#1178 C2 is Not run, so there is no prior result to invalidate; it remains relevant to monitoring after failover.

Suggested fix: update the line to Validation tasks: changes #1177 C3, #1178 C2, #1252 C5, Silo-Server/silo-apple#337 C5 (hung transcode nodes only)

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

Comment thread internal/transcodeproxy/liveness.go Resolved
Comment thread internal/transcodeproxy/liveness.go Resolved
@silo-kody

silo-kody Bot commented Oct 17, 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 ❌

@Rhainland

Copy link
Copy Markdown
Contributor Author

Evidence and validation line updated.

  • Evidence: the PR now links recordings of the web player (Chrome, desktop) for both flows, base c78d23391 against 980abf766. A local transcode node is stopped with SIGSTOP mid-playback and the player seeks past its buffer. Through the API relay, the base build resumes after 194 s and this PR after 7.5 s, with no reconnect. Through a proxy, the base build resumes after 193 s; with this PR the proxy answers 502 within 6 s, and the player shows Reconnecting, replans, and resumes after 25 s.
  • Validation: the line now reads changes #1177 C3, #1178 C2, #1252 C5, Silo-Server/silo-apple#337 C5 (hung transcode nodes only). The Problem section explains why. Those results covered killed workers and network drops, and this PR changes only what happens when a node hangs. Each case needs a re-test with a hung node after merge.

A transcode node whose process stops answering while its host still
accepts connections left every relayed request waiting until the player
gave up. Calls to a node now probe its health endpoint once they have
waited 3 seconds for headers; a node that does not answer within 2
seconds fails the call as unreachable, so the native relay moves the
transcode and the proxy answers 502 for the client to replan.

Closes Silo-Server#2296
One lost probe packet on a slow link could condemn a live node, and a
probe this host could not send (a failed name lookup, no local sockets)
counted as the node not answering. Retry an unanswered probe once and
treat local failures as inconclusive. The grace drops to 2 seconds so
a hung node is still found in about 6 seconds.
The watcher stored the hung marker before the call's compare-and-swap, so
a miss that raced an answer could re-mark a node the answer had just
cleared. The next call to the recovered node then accepted a single
missed probe. The marker is now stored only when the call is condemned.
The hung-node tests slept to let probes run. They now wait on what they
need: the probe count a node answers after, and a broadcast on each
request the fake node receives. Calls that depend on probes are bounded,
so a watch that stops probing fails the test instead of hanging it.
@Rhainland
Rhainland force-pushed the fix/2296-hung-node-failover branch from 980abf7 to ea39187 Compare October 17, 2026 01:13
@silo-kody

silo-kody Bot commented Oct 17, 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 ❌

Comment thread internal/api/handlers/playback.go Resolved
@macroscopeapp

macroscopeapp Bot commented Oct 17, 2026

Copy link
Copy Markdown

#1178 C2 is recorded as a pass, so the current description understates its validation history. The Web admin results comment records C2 re-validated on the combined #1956/#2292 build bfd02acf6 after a killed-worker scenario; it did not exercise a hung worker. This PR adds hang detection and rehomes the session, changing what Admin > Activity observes for that failure mode. The PR should explain this distinction, and C2 needs re-validation with a hung worker after merge.

Suggested wording: #1178 C2 was re-validated on bfd02acf6 for a killed worker, but not for a hung worker; this PR adds hang detection and session rehoming, so C2 needs re-validation with a hung worker after merge.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

A hung node can receive the retire stop, miss the five-second timeout,
and run the stop after it resumes, deleting the stored recipe that now
names the new node. When the stop gets no answer, write the card again
once node auth would refuse that stop.
…uring a stop

A stop that passed node auth can stall on a hung node and run its delete
after the API has stored the new node's card under the same transport id.
Read the card again before deleting and keep it when it now names another
executor.
@silo-triage silo-triage Bot added size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. and removed size/XL 500–999 added + deleted lines (all files); change volume, not priority. labels Oct 17, 2026
@silo-kody

silo-kody Bot commented Oct 17, 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 ❌
⚠️ 1 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers

…on stop

A stop that stalls before its first read of the stored recipe sees the
successor's card both times and deleted it. Keep a card whose execution
row id names another stream node, and compare against the first read only
for cards without a row id.
@silo-kody

silo-kody Bot commented Oct 17, 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 ❌
⚠️ 1 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers

A client or admin stop that lands on another API replica deletes the
moved transport's stored recipe, but this replica's copy of the session
still names the route, so the write made 60 seconds after an unanswered
retire stop put the stopped transport's card back.

Read the session's stream deny marker, past the local cache, before and
after each moved-recipe write. A stop sets the marker before it deletes
the card, so a write that finds the marker afterwards deletes the card
itself. The delayed write now fills only a missing card, so a later
move's card stays.
@silo-kody

silo-kody Bot commented Oct 17, 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 ❌
⚠️ 1 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers

h.putNodeRecipeV3(ctx, route.TransportID, card)
}
if h.sessionStopMarkedV3(ctx, sessionID) {
h.deleteNodeRecipeV3(ctx, route.TransportID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Recoverable playback state loss occurs when the initial stop-marker lookup succeeds but the post-write lookup fails: sessionStopMarkedV3 returns true, causing h.deleteNodeRecipeV3(ctx, route.TransportID) to delete the reconstruction recipe without a confirmed stop during a transient dependency failure. Return the lookup error separately, skip the initial write when the marker cannot be checked, and delete the recipe after writing only when a successful lookup confirms a stop.

Kody rule violation: Batch scoped Go lookups and bound dependency fan-out

Prompt for LLM

File internal/api/handlers/playback_transcode_rehome.go:

Line 664:

Recoverable playback state loss occurs when the initial stop-marker lookup succeeds but the post-write lookup fails: sessionStopMarkedV3 returns true, causing h.deleteNodeRecipeV3(ctx, route.TransportID) to delete the reconstruction recipe without a confirmed stop during a transient dependency failure. Return the lookup error separately, skip the initial write when the marker cannot be checked, and delete the recipe after writing only when a successful lookup confirms a stop.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

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.

Confirmed. sessionStopMarkedV3 returns true on a read error, and the post-write read has a 1 s timeout against the same Redis client as the 2 s write before it (router.go builds both from deps.RedisClient). A slow Redis can let the write succeed and the second read time out, and the card is then deleted with no stop. I'm fixing this in a commit on this branch: a read error still skips the write, but no longer undoes one.

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.

Fixed in 21fa256. sessionStopMarkedV3 now returns the read error. A read error before the write still skips it; after the write, only a read that confirms the marker deletes the card. TestMovedRecipeWriteSurvivesAnUnreadableMarker fails each read in turn: with the second read failing it fails on 6072a65 and passes now. The handlers package passes under -race.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed—that addresses the reported failure: an inconclusive stop check should prevent a new write, not justify deleting a recipe already written. Post-write deletion should require a successful lookup confirming the stop marker.

A focused regression test should cover the initial lookup succeeding with no marker, the recipe write succeeding, and the post-write lookup failing—the recipe must remain. Keep the confirmed-stop case too, to verify that a stop detected after the write still removes the recipe.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That addresses the reported issue: an unreadable marker blocks a new write, but only a confirmed stop can delete the recipe afterward.

The reported regression test covers both read-error positions, including reproducing the post-write failure on 6072a65 and passing on 21fa256a37. With the handlers package also passing under -race, this finding appears resolved. I haven’t independently inspected the commit or rerun the tests.

Quick104 and others added 4 commits October 20, 2026 18:40
Resolves the conflict in playback_transcode_rehome_test.go by keeping
both sides' new tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… read

A moved-card write reads the shared stop marker before and after writing.
An unreadable marker counted as a stop on both reads, so a Redis timeout
on the second read deleted the card just written, and the session lost
its restart recovery on the new node with no stop having happened. A read
error now skips a write but never undoes one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the probe's deadline ends a name lookup that is still running, Go's
transport returns only the deadline error, with no *net.DNSError in the
chain. probeHealth counted that as a miss, so a resolver stall on the API
or proxy host could mark a live node hung while its relay calls ran on
pooled connections. The probe now traces the lookup and treats a deadline
that lands during it as inconclusive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TestRelayWaitsOnSlowLiveNode answered its segment after a fixed 7 s. It
now answers once the relay's watch has probed the node's health twice,
which is the state the test means to reach.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

Review of 6072a65 (Claude Code with claude-opus-5-5, plus a cross-check by gpt-6.1-sol).

The hang detection is the right shape. A header deadline can't tell a hung node from a slow rebuild, and TCP keepalive still succeeds against a stopped process, so asking the node's health endpoint while the call waits is the narrowest test available. The probe client is built like the relay transport, and the extra cost per call measured about 1 KB and a few microseconds over DoTrustedNode.

Findings are inline, plus a reply on the existing thread at playback_transcode_rehome.go:664. I'm pushing fixes for the ones that say so, and a merge of main that resolves the conflict in playback_transcode_rehome_test.go by keeping both sides' tests. CI hasn't run on this head because of that conflict. The two recipe-card comments need your call.

Comment thread internal/transcodeproxy/liveness.go Resolved
Comment thread internal/transcodeproxy/liveness.go Resolved
Comment thread internal/transcodenode/server.go Resolved
@silo-kody

silo-kody Bot commented Oct 20, 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 ❌
⚠️ 1 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers

@Quick104

Quick104 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review summary

Reviewed 6072a65. Fixes pushed through 8f10704; all 17 checks pass on it.

Fit: 9/10 · Readiness: 9/10 — ready

Fit. A transcode node can hang while its host still accepts connections, and on main that leaves native playback stalled for minutes. Closing that gap is core failover work, and the probe is the narrowest test that tells a hung node from a slow rebuild. It reuses the #2342 and #1956 paths rather than adding a second failover route. The recipe-card fencing is now one rule in the store instead of a timer in the API.

Readiness. The hang detection and its tests hold up. The two medium defects in it and both recipe-card design concerns are fixed, with regression tests. What's left is minor or matches main's behavior (see Remaining).

Addressed

  • 06f1fd3: merged main, keeping both sides' new tests in playback_transcode_rehome_test.go. CI hadn't run on 6072a65 because of the conflict.
  • 21fa256: an unreadable stop marker after a write no longer deletes the card just written (the existing Kody thread). The doc and comment wording for when the delayed repair runs is corrected in the same commit.
  • fea5ec5: a name lookup still running at the probe deadline counts as inconclusive, not a miss. The probe comment now states the rule exactly.
  • 86af22f: TestRelayWaitsOnSlowLiveNode waits on two answered health probes instead of a fixed 7 s.
  • 6996693: replaces the 60 s delayed recipe rewrite. noderecipe.Store.DeleteUnlessMoved keeps a card only when its row id and URL both name another node, reading and deleting in one Redis transaction, and is used by the node's stop and force-reload teardown. A move skips the dead node's row. PutIfAbsent and the nodeauth.MaxSkew export are gone.
  • 8f10704: the node judges a card by the identity it had when it registered the job, so a row re-created under a new URL still deletes its own card. The stop-marker test hook is now atomic, which fixes a -race failure between tests.

Each fix has a regression test that fails without it. The store test ran against Redis 7. go test -race passes for transcodeproxy, nodepool, playback, noderecipe, proxy, transcodenode and api/handlers. go vet, make lint-changed and make verify-local-paths are clean. I didn't run these fixes on a live stack: they change the handling of a Redis read error and a resolver stall, which the tests reproduce directly. They don't change what the evidence recordings show.

Remaining

  • Documented, as on main: a moved transport can still lose its card to a late stop when its card has no row id (a session that predates node routing) or the old node never resolved its registration.
  • Low: a moved-card write holds the session lifecycle lock across two Redis reads and the write, so a slow Redis can delay replan or stop for that session by a few seconds. The rollback stop to a hung candidate still blocks for its 5 s timeout before the next candidate is tried; that stop predates this PR, and the PR shortens the worst case.

Validated features

The Validation tasks: line is right. The result comments on #1177 and #1178 record C3 and C2 as passed on the #1956/#2292 merge build, for a killed node. This PR changes what those cases show only for a hung node. The board tables still list both as not run. I couldn't confirm the recorded status of #1252 C5 or Silo-Server/silo-apple#337 C5 from the board script. No regression of killed or refusing nodes: those still fail at connect, and their tests pass.

User manual

No new docs issue needed. Silo-Server/siloserver.org#162 and its draft docs PR Silo-Server/siloserver.org#238 cover failover on the transcode node pages. #162 lists a node that hangs as not detected, citing #2296. Once this merges, that limit holds only for Jellyfin-protocol clients, and the failover text in #238 can say a node that crashes, hangs, or shuts down.

Apple and Android

No client change. The relay and the proxy answer 502 as they already do for an unreachable node, and the clients' existing reconnect and replan handle it. Jellyfin-protocol clients stay on a hung node until they time out, as the PR states (#2297, #2350).

Review method

Claude Code (claude-opus-5-5) with finder and verifier subagents, and one cross-provider round with gpt-6.1-sol. The first round found the DNS stall and the replan race, and confirmed the marker-read defect. Two more rounds on the recipe-card rework found four gaps in earlier versions of the rule; 6996693 and 8f10704 fix them.

Quick104 and others added 2 commits October 20, 2026 19:52
A transport moved off a hung node keeps its transport id, so the new
node's card is stored under the same key as the old one. The old node
deleted whatever card it found there, and the API covered that with a
rewrite 60 s after a failed retire stop. That left gaps: the timer lived
in one API process, a stop held behind the node's session lock could
still delete a card without a row id, force-reload teardown deleted
unconditionally, and the rewrite could bring back a transport another
replica had since replanned away from.

noderecipe.Store.DeleteUnlessMoved now reads the card and deletes it in
one Redis transaction, keeping it only when its row id and URL both name
another node (playback.RecipeExecutor.NamesAnotherNode). Any card the
node can't tell from its own is deleted as before, so a URL edit or a
re-added row never leaves a stopped transport reconstructable. The
node's stop and both force-reload deletes use it. A move also skips the
dead node's row, which may now point at a replacement process. The
delayed rewrite, PutIfAbsent and the nodeauth.MaxSkew export are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tarted under

A stop compared the stored card with the node's current registration.
A node whose stream_nodes row was re-created under a new URL while a
job ran then kept that job's own card, leaving the stopped transport
reconstructable, and a node whose registration lapsed deleted a moved
card it should have kept. The node now records its row id and URL when
it registers a job and judges the card against those at stop and
force-reload teardown.

Also makes the stop-marker test hook atomic: a move's detached recipe
write from an earlier test could still read it while the next test
replaced it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 21, 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
Quick104 merged commit c9082ba into Silo-Server:main Oct 21, 2026
20 checks passed
Quick104 added a commit that referenced this pull request Oct 21, 2026
Brings in main up to c9082ba, including #2803 (plan_active_quality_v1)
and #2579. Two conflicts, both resolved as unions: the v2 plan carries
both bandwidth_limit and active_quality, and the native server features
list both this branch's buffering_quality_v1 and playback_plan_summary_v1
and main's plan_active_quality_v1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P1 Core-path bug; painful workaround — next after P0 size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Playback doesn't fail over from a transcode node that hangs

2 participants