You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/06/24 05:26:51 UTC
[iotdb] 01/01: Revert "delete file before recovery in ratis mode (#6390)"
This is an automated email from the ASF dual-hosted git repository.
xingtanzjr pushed a commit to branch test_nosuchfile
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit a4b83c11041231bdce6aa160ad12add6f54f1a65
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Fri Jun 24 13:26:37 2022 +0800
Revert "delete file before recovery in ratis mode (#6390)"
This reverts commit a3352882f182cce7a3c1f9651d439682bdaaf462.
---
.../schemaregion/SchemaRegionMemoryImpl.java | 28 +++++++++-------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
index d42d02c334..8af29746f8 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
@@ -22,7 +22,6 @@ import org.apache.iotdb.commons.consensus.SchemaRegionId;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.file.SystemFileFactory;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -150,7 +149,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
private boolean isRecovering = true;
private volatile boolean initialized = false;
- private String storageGroupDirPath;
private String schemaRegionDirPath;
private String storageGroupFullPath;
private SchemaRegionId schemaRegionId;
@@ -177,9 +175,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
storageGroupFullPath = storageGroup.getFullPath();
this.schemaRegionId = schemaRegionId;
- storageGroupDirPath = config.getSchemaDir() + File.separator + storageGroupFullPath;
- schemaRegionDirPath = storageGroupDirPath + File.separator + schemaRegionId.getId();
-
int cacheSize = config.getSchemaRegionDeviceNodeCacheSize();
mNodeCache =
Caffeine.newBuilder()
@@ -194,14 +189,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
});
this.storageGroupMNode = storageGroupMNode;
-
- // In ratis mode, no matter create schemaRegion or recover schemaRegion, the working dir should
- // be clear first
- if (config.isClusterMode()
- && config.getSchemaRegionConsensusProtocolClass().equals(ConsensusFactory.RatisConsensus)) {
- FileUtils.deleteDirectory(new File(schemaRegionDirPath));
- }
-
init();
}
@@ -241,18 +228,25 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
}
private void initDir() throws SchemaDirCreationFailureException {
- File sgSchemaFolder = SystemFileFactory.INSTANCE.getFile(storageGroupDirPath);
+ String sgDirPath = config.getSchemaDir() + File.separator + storageGroupFullPath;
+ File sgSchemaFolder = SystemFileFactory.INSTANCE.getFile(sgDirPath);
if (!sgSchemaFolder.exists()) {
if (sgSchemaFolder.mkdirs()) {
- logger.info("create storage group schema folder {}", storageGroupDirPath);
+ logger.info("create storage group schema folder {}", sgDirPath);
} else {
if (!sgSchemaFolder.exists()) {
- logger.error("create storage group schema folder {} failed.", storageGroupDirPath);
- throw new SchemaDirCreationFailureException(storageGroupDirPath);
+ logger.error("create storage group schema folder {} failed.", sgDirPath);
+ throw new SchemaDirCreationFailureException(sgDirPath);
}
}
}
+ schemaRegionDirPath =
+ config.getSchemaDir()
+ + File.separator
+ + storageGroupFullPath
+ + File.separator
+ + schemaRegionId.getId();
File schemaRegionFolder = SystemFileFactory.INSTANCE.getFile(schemaRegionDirPath);
if (!schemaRegionFolder.exists()) {
if (schemaRegionFolder.mkdirs()) {