This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 6bc04261a1 [hotfix] Fix stackoverflow in IOManagerImpl
6bc04261a1 is described below

commit 6bc04261a1df8720ba9163d334022fd9764f6f8c
Author: JingsongLi <[email protected]>
AuthorDate: Wed May 14 11:26:46 2025 +0800

    [hotfix] Fix stackoverflow in IOManagerImpl
---
 .../apache/paimon/disk/FileChannelManagerImpl.java | 17 ++++++++++++---
 .../java/org/apache/paimon/disk/IOManagerImpl.java | 25 ++--------------------
 2 files changed, 16 insertions(+), 26 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/disk/FileChannelManagerImpl.java 
b/paimon-core/src/main/java/org/apache/paimon/disk/FileChannelManagerImpl.java
index 99690d426f..ba863fe2db 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/disk/FileChannelManagerImpl.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/disk/FileChannelManagerImpl.java
@@ -62,12 +62,17 @@ public class FileChannelManagerImpl implements 
FileChannelManager {
         // Creates directories after registering shutdown hook to ensure the 
directories can be
         // removed if required.
         this.paths = createFiles(tempDirs, prefix);
+
+        LOG.info(
+                "Created a new {} for spilling of task related data to disk 
(joins, sorting, ...). Used directories:\n\t{}",
+                FileChannelManager.class.getSimpleName(),
+                String.join("\n\t", tempDirs));
     }
 
     private static File[] createFiles(String[] tempDirs, String prefix) {
         List<File> filesList = new ArrayList<>();
-        for (int i = 0; i < tempDirs.length; i++) {
-            File baseDir = new File(tempDirs[i]);
+        for (String tempDir : tempDirs) {
+            File baseDir = new File(tempDir);
             String subfolder = String.format("paimon-%s-%s", prefix, 
UUID.randomUUID());
             File storageDir = new File(baseDir, subfolder);
 
@@ -75,7 +80,7 @@ public class FileChannelManagerImpl implements 
FileChannelManager {
                 LOG.warn(
                         "Failed to create directory {}, temp directory {} will 
not be used",
                         storageDir.getAbsolutePath(),
-                        tempDirs[i]);
+                        tempDir);
                 continue;
             }
 
@@ -123,6 +128,12 @@ public class FileChannelManagerImpl implements 
FileChannelManager {
                         .filter(File::exists)
                         .map(this::getFileCloser)
                         .collect(Collectors.toList()));
+        LOG.info(
+                "Closed {} with directories:\n\t{}",
+                FileChannelManager.class.getSimpleName(),
+                Arrays.stream(paths)
+                        .map(File::getAbsolutePath)
+                        .collect(Collectors.joining("\n\t")));
     }
 
     private AutoCloseable getFileCloser(File path) {
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/disk/IOManagerImpl.java 
b/paimon-core/src/main/java/org/apache/paimon/disk/IOManagerImpl.java
index c0858dbf28..1374f123df 100644
--- a/paimon-core/src/main/java/org/apache/paimon/disk/IOManagerImpl.java
+++ b/paimon-core/src/main/java/org/apache/paimon/disk/IOManagerImpl.java
@@ -61,7 +61,7 @@ public class IOManagerImpl implements IOManager {
         if (lazyChannelManager == null) {
             synchronized (this) {
                 if (lazyChannelManager == null) {
-                    lazyChannelManager = createFileChannelManager();
+                    lazyChannelManager = new FileChannelManagerImpl(tempDirs, 
DIR_NAME_PREFIX);
                 }
             }
         }
@@ -73,28 +73,7 @@ public class IOManagerImpl implements IOManager {
     @Override
     public void close() throws Exception {
         if (lazyChannelManager != null) {
-            closeFileChannelManager(lazyChannelManager);
-        }
-    }
-
-    private FileChannelManager createFileChannelManager() {
-        FileChannelManager channelManager = new 
FileChannelManagerImpl(tempDirs, DIR_NAME_PREFIX);
-        if (LOG.isInfoEnabled()) {
-            LOG.info(
-                    "Created a new {} for spilling of task related data to 
disk (joins, sorting, ...). Used directories:\n\t{}",
-                    FileChannelManager.class.getSimpleName(),
-                    getSpillingDirectoriesPathsString());
-        }
-        return channelManager;
-    }
-
-    private void closeFileChannelManager(FileChannelManager 
fileChannelManager) throws Exception {
-        fileChannelManager.close();
-        if (LOG.isInfoEnabled()) {
-            LOG.info(
-                    "Closed {} with directories:\n\t{}",
-                    FileChannelManager.class.getSimpleName(),
-                    getSpillingDirectoriesPathsString());
+            lazyChannelManager.close();
         }
     }
 

Reply via email to