TanYuxin-tyx commented on code in PR #20320:
URL: https://github.com/apache/flink/pull/20320#discussion_r926313613


##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/SortMergeResultPartitionReadScheduler.java:
##########
@@ -152,12 +160,34 @@ class SortMergeResultPartitionReadScheduler implements 
Runnable, BufferRecycler
 
     @Override
     public synchronized void run() {
-        Queue<SortMergeSubpartitionReader> availableReaders = 
getAvailableReaders();
-
-        Queue<MemorySegment> buffers = allocateBuffers(availableReaders);
+        Set<SortMergeSubpartitionReader> finishedReaders = new HashSet<>();
+        Queue<MemorySegment> buffers;
+        try {
+            buffers = allocateBuffers();
+        } catch (Throwable throwable) {
+            // fail all pending subpartition readers immediately if any 
exception occurs
+            LOG.error("Failed to request buffers for data reading.", 
throwable);
+            failSubpartitionReaders(getAllReaders(), throwable);

Review Comment:
   @reswqa Thanks for helping review. Good point. 
   
   In order to clear the reader in `sortedBuffers` in time, I added a check 
whether the reader is in `failedReaders` in the method 
`addPreviousAndGetNextReader`. 
   In addtion, when `allReaders` is empty, the `sortedBuffers` will be cleared 
in `removeFinishedAndFailedReaders`.



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