[ https://issues.apache.org/jira/browse/FLINK-7499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16264554#comment-16264554 ]
ASF GitHub Bot commented on FLINK-7499: --------------------------------------- Github user pnowojski commented on a diff in the pull request: https://github.com/apache/flink/pull/4581#discussion_r152825430 --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/ResultPartition.java --- @@ -267,28 +268,29 @@ public ResultPartitionType getPartitionType() { * first buffer has been added. */ public void add(Buffer buffer, int subpartitionIndex) throws IOException { - boolean success = false; + checkNotNull(buffer); try { checkInProduceState(); + } catch (Throwable t) { + buffer.recycle(); --- End diff -- I wonder if we should have some sanity illegal state detection for double recycling the buffers. For example each buffer could only be recycled once (protected by a private field in the Buffer `boolean wasRecycled`). Whenever you call `retain()`, you would get a new instance of the `Buffer`, pointing to the same memory, but with new flag (so that both original and retained buffers could be recycled independently, but each one of them only once). > double buffer release in SpillableSubpartitionView > -------------------------------------------------- > > Key: FLINK-7499 > URL: https://issues.apache.org/jira/browse/FLINK-7499 > Project: Flink > Issue Type: Sub-task > Components: Network > Affects Versions: 1.2.0, 1.1.4, 1.3.0, 1.1.5, 1.2.1, 1.2.2, 1.3.1, 1.4.0, > 1.3.2, 1.3.3 > Reporter: Nico Kruber > Assignee: Nico Kruber > Priority: Blocker > > {{SpillableSubpartitionView#releaseMemory()}} recycles its buffers twice: > once asynchronously after the write operation and once in > {{SpillableSubpartitionView#releaseMemory()}} after adding the write > operation to the queue. > 1) if {{SpillableSubpartitionView#releaseMemory()}} hits first and the buffer > is recycled, the memory region may already be reused despite the pending write > 2) If, for some reason (probably only in tests like > {{SpillableSubpartitionTest#testConsumeSpillablePartitionSpilledDuringConsume()}}?), > the buffer is retained and to be used in parallel somewhere else it may also > not be available anymore or contain corrupt data. -- This message was sent by Atlassian JIRA (v6.4.14#64029)