You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2024/10/08 04:08:54 UTC

(iotdb) branch master updated: Active Load: Fix load tsfile failed when system is read only (#13646)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2ec48d28a6c Active Load: Fix load tsfile failed when system is read only (#13646)
2ec48d28a6c is described below

commit 2ec48d28a6c057a209febad829941c3f324e97c2
Author: YC27 <76...@users.noreply.github.com>
AuthorDate: Tue Oct 8 12:08:48 2024 +0800

    Active Load: Fix load tsfile failed when system is read only (#13646)
    
    Co-authored-by: Steve Yurong Su <ro...@apache.org>
---
 .../storageengine/load/active/ActiveLoadDirScanner.java   | 13 +++++++++++++
 .../storageengine/load/active/ActiveLoadTsFileLoader.java | 15 +++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadDirScanner.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadDirScanner.java
index a9d30b8a7f7..f6c079cb060 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadDirScanner.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadDirScanner.java
@@ -20,6 +20,7 @@
 package org.apache.iotdb.db.storageengine.load.active;
 
 import org.apache.iotdb.commons.concurrent.ThreadName;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.db.storageengine.load.metrics.ActiveLoadingFilesNumberMetricsSet;
 import org.apache.iotdb.db.storageengine.load.metrics.ActiveLoadingFilesSizeMetricsSet;
 
@@ -39,6 +40,7 @@ import java.nio.file.attribute.BasicFileAttributes;
 import java.util.Arrays;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
 public class ActiveLoadDirScanner extends ActiveLoadScheduledExecutorService {
@@ -53,6 +55,8 @@ public class ActiveLoadDirScanner extends ActiveLoadScheduledExecutorService {
 
   private final Set<String> noPermissionDirs = new CopyOnWriteArraySet<>();
 
+  private final AtomicBoolean isReadOnlyLogPrinted = new AtomicBoolean(false);
+
   private final ActiveLoadTsFileLoader activeLoadTsFileLoader;
 
   public ActiveLoadDirScanner(final ActiveLoadTsFileLoader activeLoadTsFileLoader) {
@@ -72,6 +76,15 @@ public class ActiveLoadDirScanner extends ActiveLoadScheduledExecutorService {
   }
 
   private void scan() throws IOException {
+    if (CommonDescriptor.getInstance().getConfig().isReadOnly()) {
+      if (!isReadOnlyLogPrinted.get()) {
+        LOGGER.warn("Current system is read-only mode. Skip active load dir scanning.");
+        isReadOnlyLogPrinted.set(true);
+      }
+      return;
+    }
+    isReadOnlyLogPrinted.set(false);
+
     hotReloadActiveLoadDirs();
 
     for (final String listeningDir : listeningDirs) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java
index e64075ade2a..2f30da15e55 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.concurrent.IoTThreadFactory;
 import org.apache.iotdb.commons.concurrent.ThreadName;
 import org.apache.iotdb.commons.concurrent.threadpool.WrappedThreadPoolExecutor;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.db.auth.AuthorityChecker;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -77,6 +78,10 @@ public class ActiveLoadTsFileLoader {
   }
 
   public void tryTriggerTsFileLoad(String absolutePath, boolean isGeneratedByPipe) {
+    if (CommonDescriptor.getInstance().getConfig().isReadOnly()) {
+      return;
+    }
+
     if (pendingQueue.enqueue(absolutePath, isGeneratedByPipe)) {
       initFailDirIfNecessary();
       adjustExecutorIfNecessary();
@@ -211,6 +216,11 @@ public class ActiveLoadTsFileLoader {
           "Rejecting auto load tsfile {} (isGeneratedByPipe = {}) due to memory constraints, will retry later.",
           filePair.getLeft(),
           filePair.getRight());
+    } else if (status.getMessage() != null && status.getMessage().contains("read only")) {
+      LOGGER.info(
+          "Rejecting auto load tsfile {} (isGeneratedByPipe = {}) due to the system is read only, will retry later.",
+          filePair.getLeft(),
+          filePair.getRight());
     } else {
       LOGGER.warn(
           "Failed to auto load tsfile {} (isGeneratedByPipe = {}), status: {}. File will be moved to fail directory.",
@@ -235,6 +245,11 @@ public class ActiveLoadTsFileLoader {
           "Rejecting auto load tsfile {} (isGeneratedByPipe = {}) due to memory constraints, will retry later.",
           filePair.getLeft(),
           filePair.getRight());
+    } else if (e.getMessage() != null && e.getMessage().contains("read only")) {
+      LOGGER.info(
+          "Rejecting auto load tsfile {} (isGeneratedByPipe = {}) due to the system is read only, will retry later.",
+          filePair.getLeft(),
+          filePair.getRight());
     } else {
       LOGGER.warn(
           "Failed to auto load tsfile {} (isGeneratedByPipe = {}) because of an unexpected exception. File will be moved to fail directory.",