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

jackietien pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new dfca18ee1bc [To dev/1.3] Enable tolerating any exceptions and not 
block cluster initialization during schema region recover
dfca18ee1bc is described below

commit dfca18ee1bcfdefb4dbeadb1713449a534e33ebb
Author: Caideyipi <[email protected]>
AuthorDate: Fri Dec 6 16:34:28 2024 +0800

    [To dev/1.3] Enable tolerating any exceptions and not block cluster 
initialization during schema region recover
---
 .../schemaregion/impl/SchemaRegionMemoryImpl.java  | 32 ++++++++++------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
index c2717e6dd19..30312feaa32 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java
@@ -20,7 +20,6 @@
 package org.apache.iotdb.db.schemaengine.schemaregion.impl;
 
 import org.apache.iotdb.commons.consensus.SchemaRegionId;
-import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.file.SystemFileFactory;
 import org.apache.iotdb.commons.path.MeasurementPath;
@@ -167,7 +166,8 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
   private TagManager tagManager;
 
   // region Interfaces and Implementation of initialization、snapshot、recover 
and clear
-  public SchemaRegionMemoryImpl(ISchemaRegionParams schemaRegionParams) throws 
MetadataException {
+  public SchemaRegionMemoryImpl(final ISchemaRegionParams schemaRegionParams)
+      throws MetadataException {
 
     storageGroupFullPath = schemaRegionParams.getDatabase().getFullPath();
     this.schemaRegionId = schemaRegionParams.getSchemaRegionId();
@@ -198,7 +198,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
     }
 
     if 
(config.getSchemaRegionConsensusProtocolClass().equals(ConsensusFactory.RATIS_CONSENSUS))
 {
-      long memCost = config.getSchemaRatisConsensusLogAppenderBufferSizeMax();
+      final long memCost = 
config.getSchemaRatisConsensusLogAppenderBufferSizeMax();
       if (!SystemInfo.getInstance().addDirectBufferMemoryCost(memCost)) {
         throw new MetadataException(
             "Total allocated memory for direct buffer will be "
@@ -233,7 +233,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
       }
 
       isRecovering = false;
-    } catch (IOException e) {
+    } catch (final IOException e) {
       logger.error(
           "Cannot recover all schema info from {}, we try to recover as 
possible as we can",
           schemaRegionDirPath,
@@ -243,7 +243,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
   }
 
   private void initDir() throws SchemaDirCreationFailureException {
-    File sgSchemaFolder = 
SystemFileFactory.INSTANCE.getFile(storageGroupDirPath);
+    final File sgSchemaFolder = 
SystemFileFactory.INSTANCE.getFile(storageGroupDirPath);
     if (!sgSchemaFolder.exists()) {
       if (sgSchemaFolder.mkdirs()) {
         logger.info("create database schema folder {}", storageGroupDirPath);
@@ -255,7 +255,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
       }
     }
 
-    File schemaRegionFolder = 
SystemFileFactory.INSTANCE.getFile(schemaRegionDirPath);
+    final File schemaRegionFolder = 
SystemFileFactory.INSTANCE.getFile(schemaRegionDirPath);
     if (!schemaRegionFolder.exists()) {
       if (schemaRegionFolder.mkdirs()) {
         logger.info("create schema region folder {}", schemaRegionDirPath);
@@ -292,11 +292,11 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
     }
     if (usingMLog) {
       try {
-        SchemaLogWriter<ISchemaRegionPlan> logWriter = this.logWriter;
+        final SchemaLogWriter<ISchemaRegionPlan> logWriter = this.logWriter;
         if (logWriter != null) {
           logWriter.force();
         }
-      } catch (IOException e) {
+      } catch (final IOException e) {
         logger.error("Cannot force {} mlog to the schema region", 
schemaRegionId, e);
       }
     }
@@ -319,14 +319,14 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
    */
   @SuppressWarnings("squid:S3776")
   private int initFromLog() throws IOException {
-    File logFile =
+    final File logFile =
         SystemFileFactory.INSTANCE.getFile(
             schemaRegionDirPath + File.separator + 
SchemaConstant.METADATA_LOG);
 
-    long time = System.currentTimeMillis();
+    final long time = System.currentTimeMillis();
     // init the metadata from the operation log
     if (logFile.exists()) {
-      int idx;
+      final int idx;
       try (SchemaLogReader<ISchemaRegionPlan> mLogReader =
           new SchemaLogReader<>(
               schemaRegionDirPath,
@@ -338,7 +338,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
             System.currentTimeMillis() - time,
             storageGroupFullPath);
         return idx;
-      } catch (Exception e) {
+      } catch (final Exception e) {
         e.printStackTrace();
         throw new IOException("Failed to parse " + storageGroupFullPath + " 
mlog.bin for err:" + e);
       }
@@ -531,7 +531,7 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
           schemaRegionId,
           System.currentTimeMillis() - startTime);
       logger.info("Successfully load snapshot of schemaRegion {}", 
schemaRegionId);
-    } catch (IOException | IllegalPathException e) {
+    } catch (final Exception e) {
       logger.error(
           "Failed to load snapshot for schemaRegion {}  due to {}. Use empty 
schemaRegion",
           schemaRegionId,
@@ -541,11 +541,9 @@ public class SchemaRegionMemoryImpl implements 
ISchemaRegion {
         initialized = false;
         isRecovering = true;
         init();
-      } catch (MetadataException metadataException) {
+      } catch (final Exception exception) {
         logger.error(
-            "Error occurred during initializing schemaRegion {}",
-            schemaRegionId,
-            metadataException);
+            "Error occurred during initializing schemaRegion {}", 
schemaRegionId, exception);
       }
     }
   }

Reply via email to