fix: memory leak in CompactionUploader during shutdown#3464
Open
vishalmaurya850 wants to merge 1 commit into
Open
fix: memory leak in CompactionUploader during shutdown#3464vishalmaurya850 wants to merge 1 commit into
vishalmaurya850 wants to merge 1 commit into
Conversation
Signed-off-by: Vishal Maurya <vishalmaurya850@gmail.com>
vishalmaurya850
requested review from
1sonofqiu,
Gezi-lzq,
superhx and
woshigaopp
as code owners
July 17, 2026 07:56
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.
Fix memory leak in CompactionUploader during shutdown
More detailed description of your change, if necessary.
During shutdown,
CompactionUploaderleakedByteBufobjects allocated byProxyWriter.ObjectWriterbecause in-flightwriteStreamObjectoperations were not aware that the uploader was shutting down.Root cause:
shutdown()never setisAborted = true. This allowed in-flight lambdas inwriteStreamObjectandprepareObjectAndWriteto pass the abort check, allocate aDataBlockWriter(which allocates aCompositeByteBufinternally), and then chain writes on a pool that was terminating. If pendingStreamDataBlock.getDataCf()futures never completed (because upstream readers were also shutting down), the future chain hung indefinitely and thewhenCompletecleanup handler was never invoked — leaking the writer's internal buffer.Changes:
isAborted = trueinshutdown()so in-flight operations bail out early.streamSetObjectWriterafter pools terminate inshutdown().isAbortedinwriteStreamObject()immediately afterDataBlockWriterallocation to close the race window between the first check and writer creation.isAbortedguard inprepareObjectAndWrite()before writing to the stream-set object writer.Issue
Fixes #2364
Summary of testing strategy
CompactionUploaderTest(unit tests forwriteStreamObject,chainWriteStreamSetObject) continues to pass, confirming no regression in the happy path.ResourceLeakDetectorLEAK warnings in integration/E2E runs under repeated compaction-shutdown cycles.ResourceLeakDetector(set to PARANOID in test environments) will surface any remaining leaks if the fix is incomplete.Committer Checklist (excluded from commit message)