pnowojski commented on a change in pull request #15336:
URL: https://github.com/apache/flink/pull/15336#discussion_r599455125
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPool.java
##########
@@ -435,6 +435,7 @@ private boolean checkAvailability() {
return unavailableSubpartitionsCount == 0;
} else {
requestMemorySegmentFromGlobalWhenAvailable();
+ return !availableMemorySegments.isEmpty() &&
unavailableSubpartitionsCount == 0;
Review comment:
Could you maybe extract this check to maybe something like `boolean
shouldBeAvailable()`? I think it is duplicated at least once (maybe more) in
`checkConsistentAvailability()` method.
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPoolTest.java
##########
@@ -515,6 +518,27 @@ public void testIsAvailableOrNot() throws
InterruptedException {
assertTrue(availableFuture2.isDone());
}
+ /** For FLINK-20547: https://issues.apache.org/jira/browse/FLINK-20547. */
+ @Test
+ public void testConsistentAvailability() throws Exception {
+ MemorySegment segment = null;
+ BufferPool localPool = null;
+ NetworkBufferPool globalPool = new TestNetworkBufferPool(numBuffers,
memorySegmentSize);
+ try {
+ localPool = new LocalBufferPool(globalPool, 1);
+ segment =
localPool.requestBufferBuilderBlocking().getMemorySegment();
+ localPool.setNumBuffers(2);
+ } finally {
+ if (segment != null) {
+ localPool.recycle(segment);
+ }
+ if (localPool != null) {
+ localPool.lazyDestroy();
+ }
+ globalPool.destroy();
+ }
Review comment:
nit: I think it would be slightly simpler to use `CloseableRegistry`?
```
try (closeableRegistry = new CloseableRegistry()) {
...
}
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]