reswqa commented on code in PR #22148:
URL: https://github.com/apache/flink/pull/22148#discussion_r1132132505


##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/SortMergeResultPartition.java:
##########
@@ -186,6 +186,18 @@ protected void setupInternal() throws IOException {
             }
         }
 
+        // reserve the "guaranteed" buffers for this buffer pool to avoid the 
case that those
+        // buffers are taken by other result partitions and can not be 
released, which may cause
+        // deadlock
+        try {
+            for (int i = 0; i < 
bufferPool.getNumberOfRequiredMemorySegments(); ++i) {
+                
freeSegments.add(checkNotNull(bufferPool.requestMemorySegmentBlocking()));
+            }
+        } catch (Throwable throwable) {
+            freeSegments.forEach(bufferPool::recycle);
+            throw new IOException("Failed to reserve required buffers.", 
throwable);
+        }

Review Comment:
   Can we extract this logic to a method to reuse this, because 
`requestNetworkBuffers` also request buffers to guaranteed.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to