pnowojski commented on a change in pull request #8925: [FLINK-12852][network] 
Fix the deadlock occured when requesting exclusive buffers
URL: https://github.com/apache/flink/pull/8925#discussion_r302103002
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPool.java
 ##########
 @@ -177,7 +193,8 @@ public void recycle(MemorySegment segment) {
 
                final List<MemorySegment> segments = new 
ArrayList<>(numberOfSegmentsToRequest);
                try {
-                       while (segments.size() < numberOfSegmentsToRequest) {
+                       final Deadline deadline = 
Deadline.now().plus(Duration.ofMillis(requestSegmentsTimeoutInMillis));
 
 Review comment:
   This is probably a system call (which might be quite costly), could we 
restructure the code in a such way, that we make this only after first timeout 
to `availableMemorySegments.poll(2, TimeUnit.SECONDS);`?
   
   Or even remove it entirely: if `poll(2, TimeUnit.SECONDS)` returns `null` 
maybe we can assume that 2 seconds have passed and subtract that from the 
timeout time?

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


With regards,
Apache Git Services

Reply via email to