[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16532283#comment-16532283
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user asfgit closed the pull request at:

https://github.com/apache/flink/pull/6238


> 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.6.0, 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16532207#comment-16532207
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user zhijiangW commented on the issue:

https://github.com/apache/flink/pull/6238
  



> 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.6.0, 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16531492#comment-16531492
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user tillrohrmann commented on a diff in the pull request:

https://github.com/apache/flink/pull/6238#discussion_r199832400
  
--- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPool.java
 ---
@@ -151,7 +151,12 @@ public void recycle(MemorySegment segment) {
 
this.numTotalRequiredBuffers += numRequiredBuffers;
 
-   redistributeBuffers();
+   try {
+   redistributeBuffers();
+   } catch (Throwable t) {
+   this.numTotalRequiredBuffers -= 
numRequiredBuffers;
+   ExceptionUtils.rethrowIOException(t);
--- End diff --

After an offline discussion with Nico, we agreed that we should add this 
bit and additionally also call `redistributeBuffers` in the failure case in 
`requestMemorySegments`.


> 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.6.0, 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16531421#comment-16531421
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user tillrohrmann commented on a diff in the pull request:

https://github.com/apache/flink/pull/6238#discussion_r199813070
  
--- Diff: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java
 ---
@@ -396,4 +398,48 @@ public void go() throws Exception {
globalPool.destroy();
}
}
+
+   /**
+* Tests {@link NetworkBufferPool#requestMemorySegments(int)}, 
verifying it may be aborted and
+* remains in a defined state even if the waiting is interrupted.
+*/
+   @Test
+   public void testRequestMemorySegmentsInterruptable2() throws Exception {
+   final int numBuffers = 10;
+
+   NetworkBufferPool globalPool = new 
NetworkBufferPool(numBuffers, 128);
+   MemorySegment segment = globalPool.requestMemorySegment();
+   assertNotNull(segment);
+
+   final OneShotLatch isRunning = new OneShotLatch();
+   CheckedThread asyncRequest = new CheckedThread() {
+   @Override
+   public void go() throws Exception {
+   isRunning.trigger();
+   globalPool.requestMemorySegments(10);
+   }
+   };
+   asyncRequest.start();
+
+   // We want the destroy call inside the blocking part of the 
globalPool.requestMemorySegments()
+   // call above. We cannot guarantee this though but make it 
highly probable:
+   isRunning.await();
+   Thread.sleep(10);
+   asyncRequest.interrupt();
+
+   globalPool.recycle(segment);
+
+   try {
+   asyncRequest.sync();
+   } catch (IOException e) {
+   assertThat(e, hasProperty("cause", 
instanceOf(InterruptedException.class)));
+
+   // test indirectly for 
NetworkBufferPool#numTotalRequiredBuffers being correct:
+   // -> creating a new buffer pool should not fail
+   globalPool.createBufferPool(10, 10);
+   } finally {
+   globalPool.destroy();
+
--- End diff --

Remove line break.


> 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.6.0, 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16531418#comment-16531418
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user tillrohrmann commented on a diff in the pull request:

https://github.com/apache/flink/pull/6238#discussion_r199811207
  
--- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPool.java
 ---
@@ -151,7 +151,12 @@ public void recycle(MemorySegment segment) {
 
this.numTotalRequiredBuffers += numRequiredBuffers;
 
-   redistributeBuffers();
+   try {
+   redistributeBuffers();
+   } catch (Throwable t) {
+   this.numTotalRequiredBuffers -= 
numRequiredBuffers;
+   ExceptionUtils.rethrowIOException(t);
--- End diff --

Shouldn't we also do a clean up of the `LocalBufferPool` in 
`createBufferPool` if the `redistributeBuffers` fails there? 
```
try {
redistributeBuffers();
} catch (IOException e) {
destroyBufferPool(localBufferPool);
ExceptionUtils.rethrowIOException(e);
}

return localBufferPool;
```


> 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.6.0, 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16530944#comment-16530944
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user NicoK commented on the issue:

https://github.com/apache/flink/pull/6238
  
actually, it was quite easy to reproduce and the fix was also just as you 
proposed - please see the new commits (the old one was only renamed since I 
created a separate issue for that now)


> 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-03 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16530927#comment-16530927
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user NicoK commented on a diff in the pull request:

https://github.com/apache/flink/pull/6238#discussion_r199702444
  
--- 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 segments = new 
ArrayList<>(numRequiredBuffers);
--- End diff --

ah, true, thanks for pointing this out, I must have been blind on one eye 
yesterday

I'll integrate this change as well


> 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-02 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-02 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16530782#comment-16530782
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

Github user zhijiangW commented on the issue:

https://github.com/apache/flink/pull/6238
  
Thanks for fixing this bug. :)
I think there is another potential bug in polling segments from queue 
during task canceling process, and I pointed out it in the above codes.


> 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-02 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16529727#comment-16529727
 ] 

ASF GitHub Bot commented on FLINK-9636:
---

GitHub user NicoK opened a pull request:

https://github.com/apache/flink/pull/6238

[FLINK-9636][network] fix inconsistency with failed buffer redistribution

## What is the purpose of the change

If an exception is thrown in `NetworkBufferPool#requestMemorySegments()`'s 
first call to `redistributeBuffers()`, the accounting for 
`numTotalRequiredBuffers` is wrong for future uses of this buffer pool.

## Brief change log

- fix accounting of `NetworkBufferPool#numTotalRequiredBuffers` during 
failures in `NetworkBufferPool#requestMemorySegments()`
- fix some checkstyle warnings
- add a few more checks around buffer/memory segment recycling

## Verifying this change

This change added tests and can be verified as follows:
- added 
`NetworkBufferPoolTest#testRequestMemorySegmentsExceptionDuringBufferRedistribution()`

## 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: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: **no**
  - The S3 file system connector: **no**

## Documentation

  - Does this pull request introduce a new feature? **no**
  - If yes, how is the feature documented? **JavaDocs**


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/NicoK/flink flink-9636

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/6238.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #6238


commit b3e03fc93f8daa34d81b822a7cd56c353e88c4f7
Author: Nico Kruber 
Date:   2018-07-02T09:50:47Z

[hotfix][network] checkstyle

commit abc724d2ea3acc8ff1e5bf4137ed1fccb6d61372
Author: Nico Kruber 
Date:   2018-07-02T09:51:09Z

[FLINK-9636][network] fix inconsistency with failed buffer redistribution

commit 702b664d1b5b7525a620fbc0ef8121f4df882279
Author: Nico Kruber 
Date:   2018-07-02T10:42:40Z

[hotfix][network] add a few more checks and tags




> 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
>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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-07-02 Thread Nico Kruber (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16529613#comment-16529613
 ] 

Nico Kruber commented on FLINK-9636:


Actually, {{numRequiredBuffers}} is only a local variable in this method - why 
should we bother changing it?

Also, if there is an {{InterruptedException}} when polling memory segments from 
the {{availableMemorySegments}} queue, this will be re-thrown and the request 
will fail - {{NetworkBufferPool}} should then be restored to the state it was 
before which it is, isn't it?

I see only one point where the accounting for {{numTotalRequiredBuffers}} can 
be wrong: if an exception is thrown in the first of the 
{{redistributeBuffers()}} calls.

> 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
>Priority: Major
>
> In {{NetworkBufferPool#requestMemorySegments}}, {{numTotalRequiredBuffers}} 
> is increased by {{numRequiredBuffers}} first.
> If {{InterruptedExeption}} 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)


[jira] [Commented] (FLINK-9636) Network buffer leaks in requesting a batch of segments during canceling

2018-06-21 Thread zhijiang (JIRA)


[ 
https://issues.apache.org/jira/browse/FLINK-9636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16519204#comment-16519204
 ] 

zhijiang commented on FLINK-9636:
-

[~NicoK], I think this is a bug during implementing credit-based flow control.

> 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.6.0
>Reporter: zhijiang
>Priority: Major
>
> In {{NetworkBufferPool#requestMemorySegments}}, {{numTotalRequiredBuffers}} 
> is increased {{numRequiredBuffers}} first.
> If {{InterruptedExeption}} 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 not 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)