Skip to content

fix(playback): replan around a transcode or proxy node that stopped answering - #2292

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/playback-replan-around-dead-node
Oct 13, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/playback-replan-around-dead-node

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1176
Validation tasks: unblocks #1177 C3, #1178 C2; changes #1250 C5, #1252 C5 (multi-node setups only)

When a transcode node or a proxy dies mid-stream, the replan a client sends to recover can hand back the same dead route, and playback stays on a spinner. In the web player this happens whenever the node dies less than about 30 seconds before the next health sweep and media goes through a proxy, which is the default once a proxy is registered. The Activity page then keeps listing the session on the dead node as paused at 0:00.

The pool's health flag only changes at the sweep, so until then the dead node still looks healthy:

  • The web player reconnects with a track_change replan that changes nothing. That replan keeps the running HLS transport while its route is still allowed, so it returns the dead node's URL.
  • A failure_recovery replan, which the Apple and Android apps send, gets a new transport, but the session sticks to its current transcode node and is offered the same proxy again. It also counts the plan as failed, so a second recovery can end in adaptation_exhausted even though only the node failed.

A replan now first asks the session's transcode node and egress proxy whether they answer, with a two-second bound. A node that doesn't answer is left out of that replan: its capabilities aren't used for planning, its transport isn't reused, the route resolver doesn't select it, and it degrades its co-location group as a failed health check would. A recovery from such a node keeps the failed plan eligible, so the same recipe runs on another node or on this server. seek_reanchor keeps its route as before.

Approach

  • The probe calls the node's unauthenticated health endpoint, the same check the sweep runs. It runs only when the session has a remote route, and the session's nodes are probed in parallel.
  • The unreachable set rides on the request context, like the routing policy snapshot, and reaches the planner as Unreachable on nodepool.RouteRequest. Counting the node as unhealthy for group health is what keeps a grouped transcode node from being paired with another group's proxy when its own proxy died. Other proxy filters, such as network-access reachability, keep their current behavior.
  • The pool's health flag is not changed. Other sessions find out from their own replans or at the next sweep. fix(playback): move a transcode off a dead node instead of failing every segment #1956 marks an unreachable node in the pool from the API relay and moves API-relayed transcodes without a replan; the two changes don't depend on each other and merge cleanly together.
  • docs/architecture/playback-protocol-v3.md now says that keeping the current route eligible doesn't keep a dead node, and that a recovery from one doesn't exclude its plan.

Validation

  • Tests cover which nodes a replan probes for each route shape; a sticky session skipping an unreachable transcode node without contacting it; a dead proxy replaced by another proxy or by API egress; planning capability reads skipping an unreachable node; track_change and failure_recovery replans against two fake nodes, keeping a working transport and moving off a dead one with the same recipe; and the planner degrading the group of an unreachable node. The new tests fail without the change; the handler tests pass under -race.
  • End to end on a local stack: an API server, two transcode nodes in two co-location groups, one proxy, synthetic MPEG-4 Part 2 media, the web player in headless Chromium, and the node killed with SIGKILL right after a health sweep.
    • Before (main): the replan reused the dead node's transport, the player fetched the same manifest, got 502, and stayed on a spinner; Activity kept the session on the dead node.
    • After, together with fix(playback): move a transcode off a dead node instead of failing every segment #1956: playback resumed on the other node 5.6 to 7.3 seconds after a transcode node or the proxy was killed, with about 2 seconds of visible freeze; SIGTERM and deleting the node and then stopping it gave the same result. API-egress sessions showed no freeze. A scripted client that recovers like the Android app (failure_recovery) got its new plan 2.1 seconds after the first failed segment, without a stall.
    • Those runs used software encoding. With hw_accel set to auto on this macOS test host, a replan also pays about 2 seconds of local VideoToolbox detection, which put a few runs at 10.0 to 10.2 seconds; that cost isn't part of this change.
  • Gate: go build, gofmt, go vet, make lint-changed, the web lint, format, build, budget and tests, and every verify-* target pass. make test-go fails on this macOS host in apiv2, intromarkers, jellycompat, playback, proxy and transcodenode (hardware probes and timing); every failing test fails the same way on main on this host, and the packages this change touches (api/handlers, nodepool, noderouting) pass.

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

Risks

  • A replan for a session on a remote route waits for one health request per node, normally a few milliseconds and at most two seconds for a node that stops answering without closing its port.
  • A node that hangs rather than dies is still not detected on the request path, and Jellyfin-protocol clients don't fail over; both are tracked separately.

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, GitHub CLI, Playwright
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: n/a

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T21:30:33.743167Z c9b9470 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

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

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 8b513c8e-3bf0-452a-8c3e-49d80958198e
📥 Commits

Reviewing files that changed from the base of the PR and between c9b9470 and a6b9ba3.

📒 Files selected for processing (5)
  • docs/architecture/playback-protocol-v3.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_v3.go
  • internal/api/handlers/playback_v3_route_nodes_test.go
  • internal/nodepool/planner.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

Playback v3 replans probe session transcode and proxy nodes, then exclude unresponsive nodes from capability reads and route selection. Replans can retry a failed plan on another node when the current node is unreachable.

Changes: Playback v3 node reachability

Layer / File(s) Summary
Probe session nodes
internal/api/handlers/playback.go, internal/api/handlers/playback_v3_route_nodes.go, internal/api/handlers/playback_v3_route_nodes_test.go
Handlers can probe the session’s transcode node and distinct proxy node concurrently. They record unreachable URLs in request context and filter nodes using those URLs. Tests cover probing and unreachable-node reporting.
Propagate exclusions through routing
internal/nodepool/planner.go, internal/noderouting/resolver.go, internal/api/handlers/playback_v3.go, internal/nodepool/planner_test.go, internal/api/handlers/playback_v3_route_nodes_test.go
Capability reads and route eligibility omit unreachable nodes. The resolver passes exclusions to the planner, which removes matching nodes and degrades their co-location groups. Tests cover route selection, capability reads, and progressive-remux escalation.
Apply reachability during replans
internal/api/handlers/playback_v3.go, internal/api/handlers/playback_v3_route_nodes_test.go, docs/architecture/playback-protocol-v3.md
Non-seek-reanchor replans probe current session nodes. Unreachable nodes prevent transport reuse and keep failed plan keys eligible for replacement planning. Tests and architecture guidance describe these rules.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PlaybackHandler
  participant nodepool.CheckNode
  participant noderouting.Resolve
  participant PlanRoute
  PlaybackHandler->>nodepool.CheckNode: Probe session node URL
  nodepool.CheckNode-->>PlaybackHandler: Return probe result
  PlaybackHandler->>noderouting.Resolve: Pass unreachable node URLs
  noderouting.Resolve->>PlanRoute: Forward unreachable URLs
  PlanRoute-->>PlaybackHandler: Return route excluding unreachable nodes
Loading

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to a6b9b

Recovery replans avoid unreachable nodes, and no merge-blocking issue remains after normal checks.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 76.47% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 7 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 main change: replanning around an unresponsive transcode or proxy node.
Description check Passed The description directly explains the playback recovery problem, implementation, validation, risks, and scope of the changes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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

  • Fix all pre-merge checks with AI
✨ 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.

@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 11, 2026
Comment thread internal/api/handlers/playback_v3.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9b9470cf2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/api/handlers/playback_v3.go Resolved
A dead-node replan keeps the failed recipe, so a progressive remux under worker-only routing came back as a remux whose only proxy was the dead one, and failed on route capacity. Count only proxies the replan found answering when deciding whether the remux has a route. Also compare echoed plan keys trimmed, as planning does.
@silo-kody

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants