Repository navigation
fix(playback): stop seek-restart churn and premature paused-session reaping - #279
Conversation
…eaping Two latent defects (present since the initial migration) explain the cross-client freezes on resume-after-pause, intro-skip, and manual seek reported in Silo-Server#243: 1. Dueling transcode restarts. TranscodeSession.Restart had no concurrency guard, and SegmentRecoveryDecision told concurrent segment requests to restart again while a restart was already in flight (the restart window runs with running=false, so requests hit the restart-happy transcode_not_running branch before the Restarting check). Pipelined HLS segment requests therefore spawned restarts that kept killing the ffmpeg the player was waiting on — a 30s stall and another restart, surfacing as buffer-then-freeze. Restart is now single-flight and the recovery decision waits out an in-flight restart (WaitForSegment already polls politely through one). 2. Paused sessions were reaped after 2 minutes, killing the transcode with no revival path — every resume request then 404s. Clients that stop progress reporting while paused (tvOS; backgrounded web tabs) froze on play after a >5 minute pause. Paused grace is now 30 minutes in both the in-memory session manager and the DB session cleaner. Also unifies post-restart re-arming: the throttler and exit monitor are re-armed via a restart hook installed at session creation and fired by Restart itself, so the jellycompat seek path (which previously re-armed nothing) and the audio-switch path (which re-armed only the throttler) now behave identically to web segment recovery. Follow-up (not in this PR): lazily revive a reaped session's transcode on resume instead of 404ing, so even multi-hour pauses recover. Fixes Silo-Server#243 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b16cc0aef
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| case progress.Restarting: | ||
| decision.Wait = true | ||
| decision.WaitTimeout = activeSegmentWait | ||
| decision.RestartOnTimeout = false | ||
| decision.Reason = "transcode_restarting" |
There was a problem hiding this comment.
Re-decide instead of returning 404 after restart wait
When a segment request reaches this branch during an in-flight restart but the target segment is not produced within activeSegmentWait (for example a slow seek/transcode under load), RestartOnTimeout=false makes callers give up: the segment handlers only enter their recovery/restart path when the original decision has this flag set, so after WaitForSegment times out they fall through to a 404 rather than re-evaluating once the restart may have completed. This turns slow restarts into client-visible segment failures; the timeout path should re-decide or otherwise continue recovery instead of permanently disabling it here.
Useful? React with 👍 / 👎.
Code reviewFound 2 issues (both advisory — the core concurrency changes verified clean):
silo-server/internal/api/handlers/playback.go Lines 2213 to 2217 in 1b16cc0
Verified clean: the single-flight 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
…sions The comment above SetRestartHook claimed the hook covers restarts from 'jellycompat seek', but jellycompat creates its own TranscodeSessions via playback.StartTranscode in a separate registry and calls Restart directly; those sessions never get the hook and never had throttler/exit-monitor wiring to re-arm. Reword the comment (and the matching test comment) to scope the guarantee to handler-created sessions. Also fix TestRestartInvokesRestartHook to resolve `true` via PATH instead of hardcoding /bin/true, which does not exist on macOS. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Addressed the review finding in 95327c9 (comment-only, as suggested): verified that jellycompat keeps its own transcode registry ( Bonus: fixed a portability bug the test run exposed — The overlap with #174 remains a sequencing decision for the maintainer — no code change belongs in this PR for it. 🤖 Generated with Claude Code |
…eaping (Silo-Server#279) * fix(playback): stop seek-restart churn and premature paused-session reaping Two latent defects (present since the initial migration) explain the cross-client freezes on resume-after-pause, intro-skip, and manual seek reported in Silo-Server#243: 1. Dueling transcode restarts. TranscodeSession.Restart had no concurrency guard, and SegmentRecoveryDecision told concurrent segment requests to restart again while a restart was already in flight (the restart window runs with running=false, so requests hit the restart-happy transcode_not_running branch before the Restarting check). Pipelined HLS segment requests therefore spawned restarts that kept killing the ffmpeg the player was waiting on — a 30s stall and another restart, surfacing as buffer-then-freeze. Restart is now single-flight and the recovery decision waits out an in-flight restart (WaitForSegment already polls politely through one). 2. Paused sessions were reaped after 2 minutes, killing the transcode with no revival path — every resume request then 404s. Clients that stop progress reporting while paused (tvOS; backgrounded web tabs) froze on play after a >5 minute pause. Paused grace is now 30 minutes in both the in-memory session manager and the DB session cleaner. Also unifies post-restart re-arming: the throttler and exit monitor are re-armed via a restart hook installed at session creation and fired by Restart itself, so the jellycompat seek path (which previously re-armed nothing) and the audio-switch path (which re-armed only the throttler) now behave identically to web segment recovery. Follow-up (not in this PR): lazily revive a reaped session's transcode on resume instead of 404ing, so even multi-hour pauses recover. Fixes Silo-Server#243 Co-Authored-By: Claude Fable 5 <[email protected]> * docs(playback): scope the restart-hook comment to handler-created sessions The comment above SetRestartHook claimed the hook covers restarts from 'jellycompat seek', but jellycompat creates its own TranscodeSessions via playback.StartTranscode in a separate registry and calls Restart directly; those sessions never get the hook and never had throttler/exit-monitor wiring to re-arm. Reword the comment (and the matching test comment) to scope the guarantee to handler-created sessions. Also fix TestRestartInvokesRestartHook to resolve `true` via PATH instead of hardcoding /bin/true, which does not exist on macOS. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Quick <[email protected]>
Problem
Cross-client playback freezes (web + tvOS) on three state changes: resume after a long pause, intro-skip, and manual seek near stream start (#243). Investigation found two independent latent defects, both present since the initial migration:
TranscodeSession.Restarthad no concurrency guard, and the segment-recovery decision told concurrent requests to restart again while a restart was already in flight — the restart window runs withrunning=false, so requests hit the restart-happytranscode_not_runningbranch before theRestartingcase was ever reached. Pipelined HLS segment requests therefore spawned restarts that kept killing the ffmpeg the player was waiting on: a 30s stall, another restart, surfacing as buffer-then-freeze. Near stream start (tiny produced head) almost any forward seek entered this path, and intro-skip is the same code path.Approach
Restartis now single-flight: a second caller during an in-flight restart returns immediately as a no-op instead of killing the process the first restart just started.SegmentRecoveryDecisionchecksRestartingbeforeRunningand returns wait-not-restart (WaitForSegmentalready polls politely through a restart window).SessionManagerand the DBSessionCleaner), so an intentional pause survives; abandoned sessions still reap.Restartitself — previously the jellycompat seek path re-armed nothing and the audio-switch path re-armed only the throttler; now all three callers behave identically.Testing
restart_count=1); the concurrent request hit the newtranscode_restartingwait branch and got its segment in 1.4s. Old code restarted for each.Risks / follow-up
Fixes #243
AI-use disclosure
Implemented with Claude Code (test-first, live-validated); human-reviewed before submission.
🤖 Generated with Claude Code