Repository navigation
fix(playback): stop transcode startup waits when the request ends - #1499
Conversation
Fresh local transcode starts waited up to ManifestStartupTimeout (30s) per attempt for the first manifest even after the requesting client disconnected. The caller holds the session lifecycle lock for that whole wait and discards the transport once its request is gone, so the wait only blocked the client's retry on the same session. The non-auto path also went on to its startup retry, steering it away from a device that had not failed. Fresh starts now wait with the request context: on cancellation the attempt is closed without advancing or caching the hw_accel=auto pipeline, and the v3 handler returns before any retry. Reconstructs keep waiting, because every segment request queued on one shares it. FFmpeg itself still runs detached from the request once started. A transcode node whose start request is abandoned logs it at info rather than as a readiness failure; the API server already stops that remote transcode. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 8 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
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 |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused playback bug fix that stops abandoned transcode startup waits, releases lifecycle locks, and preserves existing behavior for timeout-only callers, with targeted tests and no schema or sensitive-path changes. An unresolved Medium-severity automated finding notes a cancellation race when a manifest becomes ready concurrently with request cancellation; that finding independently blocks approval. Notes:
You can add or adjust custom eligibility rules. Learn more. |
Problem
Related issue: N/A
Validation tasks: none (Hardware transcoding #1172 C2 and Distributed transcode nodes #1177 C3 are near this path but not yet run)
If a client disconnects while a local transcode is starting, the server keeps waiting up to 30s per attempt for the first HLS manifest, and meanwhile holds that playback session locked. This change stops the wait when the request ends.
prepareLocalTransportV3holdsLockSessionLifecyclefor the whole manifest wait. Withhw_accel=autothat can be up to three 30s attempts. Once the request is gone, its later steps fail and the transport is rolled back, so the wait only delays the client's retry on the same session. The non-auto path could also go on to its startup retry and setAvoidHWDeviceto a GPU that had not failed. A transcode node had the same problem with the API server's start request: it kept starting a session the API had already given up on.Approach
WaitForManifestContext,WaitForGenerationManifestContext). The existing timeout-only methods behave as before.runTranscodeStartup, a fresh start waits with the request context. On cancellation it closes the attempt and returns without advancing or caching thehw_accel=autopipeline, since a departed client says nothing about the device.The idea comes from a public fork (kipsilabs#127), which went the other way and gave startup an overall budget. Jellycompat has the same timeout-only waits (
internal/jellycompat/streams.go). This PR leaves them unchanged.Validation
go test ./internal/playback/... ./internal/transcodenode/... ./internal/api/handlers/...passes.mainthe fresh-start test waits the full 60s timeout and fails.make lint-changed: 0 issues.Risks
Checklist
AI Disclosure
ReadTimeout, lock release on the new early return, and error classification. It found no defects. It suggested keeping the existing error for failures where FFmpeg never started and quieter node logging; both are applied.🤖 Generated with Claude Code
Note
Stop transcode startup waits when the playback request ends
WaitForManifestContextandWaitForGenerationManifestContextmethods toplayback.TranscodeSession; the sharedwaitForManifestpolling now returnsctx.Err()when the context ends instead of waiting until the startup timeout (transcode.go)runTranscodeStartupcloses the session and returns aTranscodeStartupErrorwithout trying the software tone-map fallback or recording a cached result. Reconstruct starts use a non-canceling context so they outlive the triggering request (transcode_startup.go)WaitForManifestandWaitForGenerationManifestcallers now run with a background context, so their behavior is unchanged, but any caller that passes a context to the new variants must handlectx.Err()returns📊 Macroscope summarized fe284d2. 4 files reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues