Repository navigation
fix(playback): move a transcode off a node that hangs - #2579
Conversation
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:
|
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
Note Reviews pausedIt 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
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
The recorded playback-recovery cases need re-validation for hung-worker behavior; the current These are major changes: the PR must explain why validated behavior changes, and each case needs re-validation after merge.
Suggested fix: update the line to Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
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:
|
|
Evidence and validation line updated.
|
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.
980abf7 to
ea39187
Compare
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:
|
|
#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 Suggested wording: 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 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:
|
…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 — 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:
|
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 — 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:
|
| h.putNodeRecipeV3(ctx, route.TransportID, card) | ||
| } | ||
| if h.sessionStopMarkedV3(ctx, sessionID) { | ||
| h.deleteNodeRecipeV3(ctx, route.TransportID) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
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.
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:
|
Review summaryReviewed 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
Each fix has a regression test that fails without it. The store test ran against Redis 7. Remaining
Validated featuresThe User manualNo 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 AndroidNo client change. The relay and the proxy answer Review methodClaude 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. |
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 — 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:
|
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]>
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
502so 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 onbfd02acf6for 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
502so 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/healthendpoint, 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 withnodepool.ErrNodeNotAnswering, whichnodepool.IsConnectFailurecounts like a refused connection.transcodeproxy.DoNode. It wraps the native API relay, the native transcode start, and the proxy relay.docs/architecture/node-failure-detection.mdanddocs/architecture/restart-resilient-playback.mddescribe the rule. No client or API contract change. The server doesn't pushplan_invalidatedto 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 callstranscodeproxy.DoNode(s.httpClient, req, nodeURL, "stream")inside the closure. Once both land, the Jellyfin relays can useDoNode, and #2350'sNodeUnreachablecan countErrNodeNotAnswering, so Jellyfin clients move off hung nodes too. #2355 merges without new conflicts.Validation
worker_onlyand no other node, the relay answers502within the same bound. A slow node that keeps answering health is waited on, and nothing moves. The proxy answers502for a hung node. A replan's probe leaves a hung node out.-race.main, the two hung-node tests hit the client's 45-second limit with no answer.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-gofailed only in tests that fail the same way onmainon the test host: two DV-strip tests ininternal/jellycompatthat depend on the host's FFmpeg, andTestHandleStartPlaybackV3DoesNotWaitForSessionSync, 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 ofverify-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
c78d23391against this branch at980abf766(the same code is1d620624cafter a rebase ontomain), same media and settings. The transcode node is stopped withSIGSTOPmid-playback, then the player seeks past its buffer:502within 6 s; player shows Reconnecting, replans, resumes after 25 sIn the proxy case, the time after the first
502is 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
Checklist
AI Disclosure
Note
Move a hung transcode node's stream to a healthy node via liveness probes
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 withnodepool.ErrNodeNotAnsweringafter two unanswered probes (one for a node already marked hung). See liveness.go.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.StreamDeny.Lookupthat reads Redis directly with a timeout.transcodenode.recipeStorereplacesDeletewithDeleteUnlessMoved; 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.