[AMORO-4166] [Improvement]: Implement heap-based flush mechanism for SortedPosDeleteWriter to prevent OOM.#4276
Open
slfan1989 wants to merge 2 commits into
Open
[AMORO-4166] [Improvement]: Implement heap-based flush mechanism for SortedPosDeleteWriter to prevent OOM.#4276slfan1989 wants to merge 2 commits into
slfan1989 wants to merge 2 commits into
Conversation
…SortedPosDeleteWriter to prevent OOM
Contributor
Author
|
@zhoujinsong Could you please help review this PR when available? Thank you very much! |
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.
Why are the changes needed?
Close #4166.
SortedPosDeleteWritercurrently only flushes buffered position deletes based on a record count threshold, which can cause OutOfMemoryError (OOM) in memory-constrained environments when processing large-scale delete operations.There was a TODO comment in the code indicating the need for a heap memory-based flush policy:
This PR implements the heap-based flush mechanism to prevent OOM issues by monitoring JVM heap usage and triggering flush when memory pressure is detected, while maintaining backward compatibility.
Brief change log
Core Implementation:
HeapUsageProviderinterface to monitor JVM heap memory (max/used)shouldFlushByHeap()method with safety guards (minimum records, valid ratio check)delete()logic to flush whenrecords >= recordsNumThreshold || shouldFlushByHeap()Configuration:
pos-delete.flush.heap.ratio(default: 0.8) - Heap usage ratio thresholdpos-delete.flush.records(default: Long.MAX_VALUE) - Record count thresholdpos-delete.flush.heap.min-records(default: 1000) - Minimum records before heap flushHow was this patch tested?
TestSortedPosDeleteWriterHeapFlushwith mockHeapUsageProviderto test heap-based flush logicDocumentation