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

jiangtian pushed a commit to branch fix_load_directory_full
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 848021c9d2169320088ea1539919ea237f07326b
Author: Tian Jiang <[email protected]>
AuthorDate: Thu Jul 11 14:17:20 2024 +0800

    add log for full directory
---
 .../rescon/disk/strategy/SequenceStrategy.java        | 19 ++++++++++++++++++-
 .../apache/iotdb/commons/utils/JVMCommonUtils.java    |  8 +++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/strategy/SequenceStrategy.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/strategy/SequenceStrategy.java
index 82d7ff7f6e5..e838125de8f 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/strategy/SequenceStrategy.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/rescon/disk/strategy/SequenceStrategy.java
@@ -18,14 +18,20 @@
  */
 package org.apache.iotdb.db.storageengine.rescon.disk.strategy;
 
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.iotdb.commons.utils.JVMCommonUtils;
 import org.apache.iotdb.db.exception.DiskSpaceInsufficientException;
 
 import java.util.List;
+import org.apache.tsfile.fileSystem.FSFactoryProducer;
 
 public class SequenceStrategy extends DirectoryStrategy {
 
+  private static final long PRINT_INTERVAL_MS = 3600 * 1000L;
   private int currentIndex;
+  private Map<Integer, Long> dirLastPrintTimeMap = new ConcurrentHashMap<>();
 
   @Override
   public void setFolders(List<String> folders) throws 
DiskSpaceInsufficientException {
@@ -52,7 +58,18 @@ public class SequenceStrategy extends DirectoryStrategy {
 
   private int tryGetNextIndex(int start) throws DiskSpaceInsufficientException 
{
     int index = (start + 1) % folders.size();
-    while (!JVMCommonUtils.hasSpace(folders.get(index))) {
+    String dir = folders.get(index);
+    while (!JVMCommonUtils.hasSpace(dir)) {
+      File dirFile = FSFactoryProducer.getFSFactory().getFile(dir);
+
+      Long lastPrintTime = dirLastPrintTimeMap.putIfAbsent(index, -1L);
+      if (System.currentTimeMillis() - lastPrintTime > PRINT_INTERVAL_MS) {
+        long freeSpace = dirFile.getFreeSpace();
+        long totalSpace = dirFile.getTotalSpace();
+        LOGGER.warn("{} is above the warning threshold, free space {}, total 
space{}", dir,
+            freeSpace, totalSpace);
+        dirLastPrintTimeMap.put(index, System.currentTimeMillis());
+      }
       if (index == start) {
         throw new DiskSpaceInsufficientException(folders);
       }
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/JVMCommonUtils.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/JVMCommonUtils.java
index 6c7bb1909f5..04472f840dc 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/JVMCommonUtils.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/JVMCommonUtils.java
@@ -29,8 +29,12 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.stream.Stream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class JVMCommonUtils {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(JVMCommonUtils.class);
   /** Default executor pool maximum size. */
   public static final int MAX_EXECUTOR_POOL_SIZE = Math.max(100, getCpuCores() 
* 5);
 
@@ -67,7 +71,9 @@ public class JVMCommonUtils {
 
   public static double getDiskFreeRatio(String dir) {
     File dirFile = FSFactoryProducer.getFSFactory().getFile(dir);
-    dirFile.mkdirs();
+    if (!dirFile.mkdirs() && !dirFile.isDirectory()) {
+      LOGGER.error("Cannot create directory {}", dir);
+    }
     return 1.0 * dirFile.getFreeSpace() / dirFile.getTotalSpace();
   }
 

Reply via email to