fix(orchestrator): ensure input tempfile cleanup on all exit paths#3888
Closed
chengyixu wants to merge 1 commit intolivepeer:masterfrom
Closed
fix(orchestrator): ensure input tempfile cleanup on all exit paths#3888chengyixu wants to merge 1 commit intolivepeer:masterfrom
chengyixu wants to merge 1 commit intolivepeer:masterfrom
Conversation
Move the input *.tempfile cleanup into a deferred function so it runs on all exit paths including panics from UnrecoverableError. Previously, when Transcode() returned an UnrecoverableError the panic at line 749 bypassed the explicit os.Remove call, causing tempfiles to accumulate in the orchestrator's work directory over time. Changes: - Add deferred cleanup for fnamep that runs on normal return, error, and panic paths - Preserve existing keepInput behavior for extremely large outputs - Remove now-redundant cleanup from terr() helper and explicit os.Remove - Add regression tests for both panic and normal error cleanup paths Fixes livepeer#1716
Collaborator
|
We want to keep the tempfile on error for later inspection. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1716
/claim #1716
Problem
When
Transcode()returns anUnrecoverableError,transcodeSegpanics (line 749). This panic bypasses the explicitos.Remove(fname)call at line 799, leaving*.tempfileinput files on disk. Over time, this fills up the orchestrator's data directory.The
terr()error helper also cleaned up the file, but it is never reached on the panic path.Solution
Move the input tempfile cleanup into a deferred function at the top of
transcodeSegso it executes on all exit paths:terr()UnrecoverableErrorThe existing
keepInputflag (for preserving input when extremely large outputs are detected) is hoisted to function scope so the defer can check it.Changes
core/orchestrator.go: Adddefercleanup forfnamep; remove redundant cleanup fromterr()and the explicitos.Removeblockcore/livepeernode_test.go: Add two regression tests:TestTranscodeSegCleansTempfileOnUnrecoverableError— triggers panic path, asserts no leftover tempfileTestTranscodeSegCleansTempfileOnNormalError— triggers normal error path, asserts no leftover tempfileTesting
TestTranscodeAndBroadcastcontinues to pass (deferred cleanup handles the normal path)