lgbo-ustc commented on code in PR #12327:
URL: https://github.com/apache/gluten/pull/12327#discussion_r3510158406


##########
gluten-flink/runtime/src/main/java/org/apache/gluten/table/runtime/operators/GlutenTwoInputOperator.java:
##########
@@ -234,18 +262,33 @@ public void processWatermark2(Watermark mark) throws 
Exception {
     processElementInternal();
   }
 
+  @Override
+  public void endInput(int inputId) throws Exception {
+    switch (inputId) {
+      case 1:
+        leftInputEnded = true;
+        if (leftInputQueue != null) {
+          leftInputQueue.noMoreInput();
+        }
+        break;
+      case 2:
+        rightInputEnded = true;
+        if (rightInputQueue != null) {
+          rightInputQueue.noMoreInput();
+        }
+        break;
+      default:
+        throw new IllegalArgumentException("Unknown input id: " + inputId);
+    }
+  }
+
   @Override
   public void close() throws Exception {
     closing = true;
     GlutenCloseables.runWithCleanup(
         () -> {
-          if (leftInputQueue != null) {
-            leftInputQueue.close();
-          }
-        },
-        () -> {
-          if (rightInputQueue != null) {
-            rightInputQueue.close();
+          if (task != null) {
+            finishTask();

Review Comment:
   A possible fix is to move the final drain to the bounded completion path 
instead of `close()`: in `endInput(int inputId)`, call `noMoreInput()` for the 
corresponding queue, set the ended flag, and when both `leftInputEnded && 
rightInputEnded`, call `finishTask()` there. Then keep `close()` limited to 
cleanup only: unbind the callback target, close/cancel the native task, close 
the input queues, close the session resource, and call `super.close()`. This 
keeps final output production in Flink's head-to-tail finish/end-input phase 
and avoids producing records during the tail-to-head close phase.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to