fix(batchrouter): file descriptor leak in upload() — outputFile never closed - #7106
Closed
kuntal1461 wants to merge 2 commits into
Closed
kuntal1461 wants to merge 2 commits into
kuntal1461 wants to merge 2 commits into
Conversation
Contributor
|
This PR is considered to be stale. It has been open 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR. |
Rebaka8
approved these changes
Jul 11, 2026
Rebaka8
left a comment
There was a problem hiding this comment.
Verified that the deferred outputFile.Close() is placed immediately after os.Open(), ensuring the file descriptor is released on both successful and error execution paths. The implementation is minimal, addresses the reported resource leak, and follows the existing resource cleanup pattern used elsewhere in the project. Looks good to me.
5 tasks
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.
Closes #7071
Summary
outputFileis opened viaos.Open(gzipFilePath)inHandle.upload()but never closed — leaking one file descriptor on every batch upload call, on both the success and error return paths.Fix
Added
defer func() { _ = outputFile.Close() }()immediately afteros.Open, matching the existing pattern inarchiver/worker.go:187.Impact without fix
upload()is called on every batch job cycle for every active destination. Each call leaks one fd. Under sustained load this exhausts the process fd limit (ulimit -n), causingtoo many open fileserrors — dropped events or a crashed process.Test plan
go test ./router/batchrouter/...passes