hudi-agent commented on code in PR #18756:
URL: https://github.com/apache/hudi/pull/18756#discussion_r3251922214


##########
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:
   🤖 nit: the `10` here is a magic number — could you extract it into a named 
constant like `ASYNC_EXECUTOR_TERMINATION_TIMEOUT_MINUTES` so a future reader 
knows this value is intentional rather than arbitrary?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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