[
https://issues.apache.org/jira/browse/FLINK-31244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17694485#comment-17694485
]
Xintong Song commented on FLINK-31244:
--------------------------------------
IIRC, the conclusions of previous discussions were:
1. A memory segment should not be freed multiple times, because that indicates
design flaws that the ownership of the memory segment is unclear.
2. It's hard to tell whether there are existing cases that may lead to a memory
segment being freed multiple times, even with the CI tests. So we did not throw
an exception for it in production. The exception will only be thrown for CI
tests, in order to catch and fix such multiple freeing cases.
3. Ensuring the cleaner is only called once even if the segment is freed
multiple times is more like a safety net.
In this test case, the exception is thrown from another thread and is uncaught,
thus the test did not fail. Obviously, this is undesired and should be fixed.
In fact, I wonder if we should change it to through the exception for multiple
freeing of segment by default, and preserve the switch for falling back in case
of bad cases.
> OffHeapUnsafeMemorySegmentTest.testCallCleanerOnceOnConcurrentFree prints
> IllegalStateException
> -----------------------------------------------------------------------------------------------
>
> Key: FLINK-31244
> URL: https://issues.apache.org/jira/browse/FLINK-31244
> Project: Flink
> Issue Type: Bug
> Components: Runtime / Network, Tests
> Affects Versions: 1.17.0, 1.15.3, 1.16.1
> Reporter: Matthias Pohl
> Priority: Major
> Labels: starter, test-stability
>
> We're observing strange IllegalStateException stacktrace output in
> {{OffHeapUnsafeMemorySegmentTest.testCallCleanerOnceOnConcurrentFree}} in CI
> like:
> [https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=46283&view=logs&j=4d4a0d10-fca2-5507-8eed-c07f0bdf4887&t=7b25afdf-cc6c-566f-5459-359dc2585798&l=5584]
>
> {code:java}
> Feb 18 03:58:47 [INFO] Running
> org.apache.flink.core.memory.OffHeapUnsafeMemorySegmentTest
> Exception in thread "Thread-13" java.lang.IllegalStateException:
> MemorySegment can be freed only once!
> at org.apache.flink.core.memory.MemorySegment.free(MemorySegment.java:244)
> at java.lang.Thread.run(Thread.java:748)
> Exception in thread "Thread-15" java.lang.IllegalStateException:
> MemorySegment can be freed only once!
> at org.apache.flink.core.memory.MemorySegment.free(MemorySegment.java:244)
> at java.lang.Thread.run(Thread.java:748)
> Exception in thread "Thread-17" java.lang.IllegalStateException:
> MemorySegment can be freed only once!
> at org.apache.flink.core.memory.MemorySegment.free(MemorySegment.java:244)
> at java.lang.Thread.run(Thread.java:748){code}
> This is caused by FLINK-21798. The corresponding system property is enabled
> as part of the CI run (see
> [tools/ci/test_controller.sh:108|https://github.com/apache/flink/blob/7e37d59f834bca805f5fbee99db87eb909d1814f/tools/ci/test_controller.sh#L108])
> which makes the {{IllegalStateException}} to be thrown.
> AFAIU, the intention of this test was to make sure that the cleaner logic is
> only called once even if the free method is called multiple times.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)