[FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest#28359
Open
sherry255 wants to merge 1 commit into
Open
Conversation
Collaborator
…ent free in OffHeapUnsafeMemorySegmentTest When two threads free the same MemorySegment concurrently and the multiple-free check is enabled (flink.tests.check-segment-multiple-free, set in CI), the thread that loses the race throws an IllegalStateException. Because free() was used directly as the thread body, that expected exception surfaced as an uncaught exception and polluted the CI logs. Wrap the free() call so the expected exception is captured; the test still asserts the cleaner runs exactly once.
2a635f4 to
1f6c607
Compare
spuru9
reviewed
Jun 8, 2026
| try { | ||
| segment.free(); | ||
| } catch (IllegalStateException e) { | ||
| // On concurrent free() the thread that loses the race observes the |
Contributor
There was a problem hiding this comment.
nit: adding these comments to the flink code for each debug could make the code lengthy. Can you shorten it? Reference to jira and detail debug could be reduced.
Contributor
|
Also make sure that you're following the AI guidelines |
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.
What is the purpose of the change
Fixes FLINK-31244.
OffHeapUnsafeMemorySegmentTest.testCallCleanerOnceOnConcurrentFreestarts two threads that both call
segment.free()on the sameMemorySegmenttoverify the cleaner runs exactly once. When the multiple-free check is enabled
(
-Dflink.tests.check-segment-multiple-free, which is set in CI), the thread thatloses the race throws
IllegalStateException("MemorySegment can be freed only once!").Because
free()was used directly as the thread body, that expected exception wasraised as an uncaught exception in the worker thread and printed to the CI logs as
noise, e.g.:
The test still passed; only the logs were polluted.
Brief change log
segment.free()call in aRunnablethat catches the expectedIllegalStateException, so it is no longer surfaced as an uncaught exception. Theexisting assertion that the cleaner ran exactly once is unchanged.
Verifying this change
This change is a test-only fix and can be verified as follows:
OffHeapUnsafeMemorySegmentTest#testCallCleanerOnceOnConcurrentFreewith
-Dflink.tests.check-segment-multiple-freepasses but printsException in thread "Thread-N" java.lang.IllegalStateException: MemorySegment can be freed only once!.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation