Skip to content

fix(warehouse): close load file descriptor in identity uploadFile - #7186

Open
andyosyndoh wants to merge 1 commit into
rudderlabs:masterfrom
andyosyndoh:fix/identity-fd-leak-7185
Open

fix(warehouse): close load file descriptor in identity uploadFile#7186
andyosyndoh wants to merge 1 commit into
rudderlabs:masterfrom
andyosyndoh:fix/identity-fd-leak-7185

Conversation

@andyosyndoh

Copy link
Copy Markdown

Description

uploadFile() in warehouse/identity/identity.go opened 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. Since uploadFile() 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:

  • adds defer func() { _ = outputFile.Close() }() immediately after the os.Open, matching the pattern used elsewhere in the package (identity.go tableRows.Close()) and in warehouse/validations/validate.go
  • replaces the panic(err) on open failure with a wrapped error return, consistent with every other error path in the function

Same 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

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

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
@contributor-support

Copy link
Copy Markdown

Thank you @andyosyndoh for contributing this PR.
Please sign the Contributor License Agreement (CLA) before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(warehouse/identity): file descriptor leak in uploadFile() — outputFile never closed

1 participant