-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix Memory Leaks and Improve Cleanup in S3 Multipart Upload #15210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kumarpritam863
wants to merge
18
commits into
apache:main
Choose a base branch
from
kumarpritam863:fix/s3-multipart-upload-cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+67
−10
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c0a2665
added metadat and data path in case of dynamic routing
67619ec
spotless
6b15ae4
Revert "spotless"
8398e4c
Revert "added metadat and data path in case of dynamic routing"
fbf52a9
Merge branch 'apache:main' into main
kumarpritam863 c92ec66
Merge branch 'apache:main' into main
kumarpritam863 9392a6d
Merge branch 'apache:main' into main
kumarpritam863 ecd8b55
Merge branch 'apache:main' into main
kumarpritam863 5e76e04
Merge branch 'apache:main' into main
kumarpritam863 a1ec7e6
Merge branch 'apache:main' into main
kumarpritam863 4eaf70b
Merge branch 'apache:main' into main
kumarpritam863 1508513
Merge branch 'apache:main' into main
kumarpritam863 e5908c8
Merge branch 'apache:main' into main
kumarpritam863 cbefe9a
Merge branch 'apache:main' into main
kumarpritam863 e1cb5be
Clear staging files and multipart map on completion
kumarpritam863 21711a9
added test cases to very the clearance of staging files and multiPart…
8f18332
fixed spotless errors
30a287a
removed reflection
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its fine to do eager cleanup
though wouldn't the stream post abort closed and hence GCed ? is this staying in memory for long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @singhpk234 for the review.
Regarding memory management:
While the staging files list will eventually allow objects to be garbage-collected once they go out of scope, I’m concerned that retaining strong references to many FileAndDigest objects (especially in upload-heavy / long-running workloads) can still cause practical issues:
Even though the theoretical lifetime is finite, the practical memory pressure and GC overhead seem non-negligible in our use case.
Also although it does not effect the AWS multipart upload as AWS requires the part number to be unique but starting the part number from 1 and keeping it in low bounds make managing CompleteMultipartUpload requests easier. Currently the part number comes from the Index() of the part-file from staging files list which can start from a higher number if the previous files are not cleared.
Please let me know your thoughts on these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any harm in clearing these eagerly, but I'd agree with @singhpk234 that this isn't practically going to help. The output stream is bound to a single file write and these references will be kept as long as the stream is open regardless. So the only narrow scenario where you get some benefit is if something is holding onto the output stream references even after they're closed (which is odd in practice).
This isn't a leak and I question the validity of the examples. The memory will be held when writing, but released when closed and dereferenced.