[flink][test] Fix OOM when startTaskManager in FlinkMetricsITCase#2864
Open
Prajwal-banakar wants to merge 1 commit intoapache:mainfrom
Open
[flink][test] Fix OOM when startTaskManager in FlinkMetricsITCase#2864Prajwal-banakar wants to merge 1 commit intoapache:mainfrom
Prajwal-banakar wants to merge 1 commit intoapache:mainfrom
Conversation
Contributor
Author
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.
Purpose
Linked issue: close #2744
Fixes an OutOfMemoryError: Could not allocate enough memory segments for NetworkBufferPool that occurred when TaskManagerRunner.startTaskManager was called in FlinkMetricsITCase (and its Flink-version subclasses Flink119MetricsITCase, Flink120MetricsITCase, etc.) during sequential IT case execution in the same JVM fork.
Brief change log
The root cause is that MiniClusterWithClientResource allocates JVM direct memory via NetworkBufferPool during before(), and this memory was not reliably released between test classes, exhausting the JVM direct memory budget for subsequent classes.
Three changes were made to FlinkMetricsITCase:
beforeAll: Wrap MINI_CLUSTER_EXTENSION.before() in a try/catch that explicitly calls MINI_CLUSTER_EXTENSION.after() on failure. JUnit 5 does not invoke @afterall when @BeforeAll throws, so without this, any direct memory partially allocated before the failure would never be freed.
afterAll: Wrap resource cleanup in a try/finally block so that MINI_CLUSTER_EXTENSION.after() is always called even if admin.close() or conn.close() throws.
buildTestConfig: Reduce the NetworkBufferPool size from the default 64MB to 32MB via taskmanager.memory.network.min/max. These tests do not exercise high-throughput network paths, so the smaller size is sufficient and reduces direct memory pressure when multiple IT cases run in the same JVM fork.
Tests
Flink118MetricsITCase — passes
Flink119MetricsITCase — passes
Flink120MetricsITCase — passes
Flink22MetricsITCase — passes
Full fluss-flink-1.20 module (mvn verify -pl fluss-flink/fluss-flink-1.20 -am) — BUILD SUCCESS (225 IT tests, 0 failures), confirming no regressions introduced by this change
API and Format
No API or storage format changes
Documentation
No new feature introduced. No documentation changes required.