[
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16530783#comment-16530783
]
ASF GitHub Bot commented on FLINK-9636:
---------------------------------------
Github user zhijiangW commented on a diff in the pull request:
https://github.com/apache/flink/pull/6238#discussion_r199676237
--- Diff:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPool.java
---
@@ -147,7 +151,12 @@ public void recycle(MemorySegment segment) {
this.numTotalRequiredBuffers += numRequiredBuffers;
- redistributeBuffers();
+ try {
+ redistributeBuffers();
+ } catch (Throwable t) {
+ this.numTotalRequiredBuffers -=
numRequiredBuffers;
+ ExceptionUtils.rethrowIOException(t);
+ }
}
final List<MemorySegment> segments = new
ArrayList<>(numRequiredBuffers);
--- End diff --
The following `availableMemorySegments.poll(2, TimeUnit.SECONDS) ` may
cause `InterruptedException`, and in the catch part
`recycleMemorySegments(segments)` it will do `numTotalRequiredBuffers -=
segments.size();`.
I think we should do `recycleMemorySegments(numRequiredBuffers ,segments)`,
and then call `numTotalRequiredBuffers -= numRequiredBuffers;` inside it,
otherwise the `numTotalRequiredBuffers` is leaked.
> Network buffer leaks in requesting a batch of segments during canceling
> -----------------------------------------------------------------------
>
> Key: FLINK-9636
> URL: https://issues.apache.org/jira/browse/FLINK-9636
> Project: Flink
> Issue Type: Bug
> Components: Network
> Affects Versions: 1.5.0, 1.6.0
> Reporter: zhijiang
> Assignee: Nico Kruber
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.5.1
>
>
> In {{NetworkBufferPool#requestMemorySegments}}, {{numTotalRequiredBuffers}}
> is increased by {{numRequiredBuffers}} first.
> If {{InterruptedException}} is thrown during polling segments from the
> available queue, the requested segments will be recycled back to
> {{NetworkBufferPool}}, {{numTotalRequiredBuffers}} is decreased by the number
> of polled segments which is now inconsistent with {{numRequiredBuffers}}. So
> {{numTotalRequiredBuffers}} in {{NetworkBufferPool}} leaks in this case, and
> we can also decrease {{numRequiredBuffers}} to fix this bug.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)