You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(batchrouter): file descriptor leak in upload() — outputFile never closed #7071
In router/batchrouter/handle.go, the upload() function opens a gzip file for uploading to object storage but never closes the file descriptor, regardless of whether the upload succeeds or fails.
Location
router/batchrouter/handle.go — function upload(), line 384
Code
outputFile, err:=os.Open(gzipFilePath)
iferr!=nil {
panic(err)
}
// ❌ no defer outputFile.Close() here// ... ~70 lines of code ...uploadOutput, err:=uploader.Upload(context.TODO(), outputFile, keyPrefixes...)
iferr!=nil {
returnUploadResult{Error: err, ...} // fd leaked
}
returnUploadResult{...} // fd also leaked on success
Impact
upload() is called on every batch job cycle for every active destination. Each call leaks one OS file descriptor. Under sustained load this will exhaust the process's fd limit (ulimit -n), causing new os.Open / socket calls to fail with too many open files — which surfaces as dropped events or a crashed process.
Expected Behaviour
The file descriptor should be closed after the upload completes (success or failure).
Hi, @achettyiitr I noticed another contributor expressed interest in this issue a few days ago. If it becomes available or there's no progress, I'd be happy to help with a fix.
Activity
contributor-support commentedon Jun 8, 2026
Thanks for opening this issue! We'll get back to you shortly. If it is a bug, please make sure to add steps to reproduce the issue.
yashspokle commentedon Jun 10, 2026
I'd like to work on this issue. The fix seems straightforward (adding a deferred close for the opened file descriptor in upload()).
Could you please assign it to me?
Rebaka8 commentedon Jun 13, 2026
Hi, @achettyiitr I noticed another contributor expressed interest in this issue a few days ago. If it becomes available or there's no progress, I'd be happy to help with a fix.
fix(warehouse): close load file descriptor in identity uploadFile (#7186