You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "sherry255 (via GitHub)" <gi...@apache.org> on 2026/06/08 09:44:26 UTC
[PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
sherry255 opened a new pull request, #28359:
URL: https://github.com/apache/flink/pull/28359
## What is the purpose of the change
Fixes FLINK-31244. `OffHeapUnsafeMemorySegmentTest.testCallCleanerOnceOnConcurrentFree`
starts two threads that both call `segment.free()` on the same `MemorySegment` to
verify 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 that
loses the race throws `IllegalStateException("MemorySegment can be freed only once!")`.
Because `free()` was used directly as the thread body, that *expected* exception was
raised as an uncaught exception in the worker thread and printed to the CI logs as
noise, e.g.:
```
Exception in thread "Thread-13" java.lang.IllegalStateException: MemorySegment can be freed only once!
```
The test still passed; only the logs were polluted.
## Brief change log
- Wrap the concurrent `segment.free()` call in a `Runnable` that catches the expected
`IllegalStateException`, so it is no longer surfaced as an uncaught exception. The
existing 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:
- Before: running `OffHeapUnsafeMemorySegmentTest#testCallCleanerOnceOnConcurrentFree`
with `-Dflink.tests.check-segment-multiple-free` passes but prints
`Exception in thread "Thread-N" java.lang.IllegalStateException: MemorySegment can be freed only once!`.
- After: the same run passes with no such exception printed.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
Posted by "sherry255 (via GitHub)" <gi...@apache.org>.
sherry255 commented on PR #28359:
URL: https://github.com/apache/flink/pull/28359#issuecomment-4669171223
Thanks @spuru9 — shortened the comment, keeping just the rationale and the JIRA reference.
@MartijnVisser thanks for the pointer. I've updated the PR description to disclose the generative AI tooling used (checked the box + added the `Generated-by` line per the template). I take responsibility for the correctness and quality of every line in this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
Posted by "sherry255 (via GitHub)" <gi...@apache.org>.
sherry255 commented on PR #28359:
URL: https://github.com/apache/flink/pull/28359#issuecomment-4648726866
@flinkbot run azure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
Posted by "Jackeyzhe (via GitHub)" <gi...@apache.org>.
Jackeyzhe commented on PR #28359:
URL: https://github.com/apache/flink/pull/28359#issuecomment-4732372680
Thanks for the patch.
I ran:
`./mvnw -pl flink-core -Dtest=OffHeapUnsafeMemorySegmentTest -Dflink.tests.check-segment-multiple-free=true test`
and the targeted test passed locally. Given that the expected `IllegalStateException` is only swallowed in the losing concurrent-free thread and the cleaner-once assertion is unchanged, I do not see a blocker from this patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
Posted by "MartijnVisser (via GitHub)" <gi...@apache.org>.
MartijnVisser commented on PR #28359:
URL: https://github.com/apache/flink/pull/28359#issuecomment-4653986057
Also make sure that you're following the AI guidelines
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
Posted by "spuru9 (via GitHub)" <gi...@apache.org>.
spuru9 commented on code in PR #28359:
URL: https://github.com/apache/flink/pull/28359#discussion_r3376618478
##########
flink-core/src/test/java/org/apache/flink/core/memory/OffHeapUnsafeMemorySegmentTest.java:
##########
@@ -80,8 +80,22 @@ void testCallCleanerOnceOnConcurrentFree() throws InterruptedException {
final MemorySegment segment =
MemorySegmentFactory.allocateOffHeapUnsafeMemory(10, null, cleaner);
- final Thread t1 = new Thread(segment::free);
- final Thread t2 = new Thread(segment::free);
+ final Runnable free =
+ () -> {
+ try {
+ segment.free();
+ } catch (IllegalStateException e) {
+ // On concurrent free() the thread that loses the race observes the
Review 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28359:
URL: https://github.com/apache/flink/pull/28359#issuecomment-4647606672
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "2a635f46791e6c07a709a11c7f2a245f5f2b2149",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "2a635f46791e6c07a709a11c7f2a245f5f2b2149",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2a635f46791e6c07a709a11c7f2a245f5f2b2149 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-31244][core] Capture expected IllegalStateException on concurrent free in OffHeapUnsafeMemorySegmentTest [flink]
Posted by "sherry255 (via GitHub)" <gi...@apache.org>.
sherry255 commented on PR #28359:
URL: https://github.com/apache/flink/pull/28359#issuecomment-4650414392
@flinkbot run azure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org