fix(warehouse): close load file descriptor in identity uploadFile - #7186
Open
andyosyndoh wants to merge 1 commit into
Open
fix(warehouse): close load file descriptor in identity uploadFile#7186andyosyndoh wants to merge 1 commit into
andyosyndoh wants to merge 1 commit into
Conversation
The load file opened in uploadFile() was never closed on any path, leaking two file descriptors per identity-resolution sync. Also return an error instead of panicking when the file cannot be opened, matching the error handling of the rest of the function. Resolves rudderlabs#7185
|
Thank you @andyosyndoh for contributing this PR. |
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.
Description
uploadFile()inwarehouse/identity/identity.goopened the load file for object-storage upload but never closed the file descriptor — on the filemanager-creation error path, the upload error path, or on success. SinceuploadFile()runs twice per identity-resolution sync (merge rules + identity mappings), every sync leaked two file descriptors for the lifetime of the process, contributing to fd exhaustion (too many open files) under sustained syncing.This PR:
defer func() { _ = outputFile.Close() }()immediately after theos.Open, matching the pattern used elsewhere in the package (identity.gotableRows.Close()) and inwarehouse/validations/validate.gopanic(err)on open failure with a wrapped error return, consistent with every other error path in the functionSame defect class as #7071 (batchrouter), but in the identity-resolution flow.
Resolves #7185
Linear Ticket
N/A — community contribution, tracked in GitHub issue #7185
Security