codope commented on code in PR #18756:
URL: https://github.com/apache/hudi/pull/18756#discussion_r3251938929


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/append/AppendWriteFunctionWithBIMBufferSort.java:
##########
@@ -228,8 +229,15 @@ private void sortAndSend(BinaryInMemorySortBuffer buffer) 
throws IOException {
   @Override
   public void close() throws Exception {
     try {
-      if (asyncWriteExecutor != null && !asyncWriteExecutor.isShutdown()) {
-        asyncWriteExecutor.shutdown();
+      if (asyncWriteExecutor != null) {
+        if (!asyncWriteExecutor.isShutdown()) {
+          asyncWriteExecutor.shutdown();
+        }
+        // Do not release the sort buffers while an already-submitted flush is 
still using them.
+        waitForAsyncWriteCompletion();
+        if (!asyncWriteExecutor.awaitTermination(10, TimeUnit.MINUTES)) {

Review Comment:
   Extracting to constant is a good suggestion. Also, should it be 
configurable? I think that's unnecessary but will defer to your judgement.



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