StephanEwen commented on a change in pull request #14184:
URL: https://github.com/apache/flink/pull/14184#discussion_r529540130



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/operators/BatchTask.java
##########
@@ -893,21 +896,34 @@ protected void resetAllInputs() throws Exception {
                                        }
                                } else {
                                        // close the async barrier if there is 
one
-                                       if (this.tempBarriers[i] != null) {
-                                               this.tempBarriers[i].close();
-                                               this.tempBarriers[i] = null;
-                                       }
+                                       List<MemorySegment> allocated = 
tempBarriers[i] == null ? emptyList() :
+                                               
tempBarriers[i].closeAndGetLeftoverMemory();
+                                       tempBarriers[i] = null;
 
-                                       // recreate the local strategy
-                                       initInputLocalStrategy(i);
+                                       try {
+                                               initInputLocalStrategy(i);
 
-                                       if (this.inputIsAsyncMaterialized[i]) {
-                                               final int pages = 
this.materializationMemory[i];
-                                               @SuppressWarnings({ 
"unchecked", "rawtypes" })
-                                               TempBarrier<?> barrier = new 
TempBarrier(this, getInput(i), this.inputSerializers[i], memMan, ioMan, pages);
-                                               barrier.startReading();
-                                               this.tempBarriers[i] = barrier;
-                                               this.inputs[i] = null;
+                                               if 
(this.inputIsAsyncMaterialized[i]) {
+                                                       final int pages = 
this.materializationMemory[i];
+                                                       if (pages > 
allocated.size()) {

Review comment:
       This condition seems the wrong way around.




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


Reply via email to