You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by lt...@apache.org on 2019/12/09 07:38:39 UTC

[incubator-iotdb] branch master updated: fix a bug of re-load the same external tsfile will lead to read-only mode

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 57488f2  fix a bug of re-load the same external tsfile will lead to read-only mode
     new 83cbb32  Merge branch 'master' of github.com:apache/incubator-iotdb
57488f2 is described below

commit 57488f2158e932f6f7ec2b121acf66bd19cf0371
Author: lta <li...@163.com>
AuthorDate: Mon Dec 9 15:36:52 2019 +0800

    fix a bug of re-load the same external tsfile will lead to read-only mode
---
 .../engine/storagegroup/StorageGroupProcessor.java | 39 +++++++++++++---------
 .../iotdb/db/qp/executor/QueryProcessExecutor.java |  2 +-
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index ead863e..7cb774b 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -1165,8 +1165,9 @@ public class StorageGroupProcessor {
       loadTsFileByType(LoadTsFileType.LOAD_SEQUENCE, tsfileToBeInserted, newTsFileResource,
           getBinarySearchIndex(newTsFileResource));
       updateLatestTimeMap(newTsFileResource);
-    } catch (TsFileProcessorException | DiskSpaceInsufficientException e) {
-      logger.error("Failed to append the tsfile {} to storage group processor {}.",
+    } catch (DiskSpaceInsufficientException e) {
+      logger.error(
+          "Failed to append the tsfile {} to storage group processor {} because the disk space is insufficient.",
           tsfileToBeInserted.getAbsolutePath(), tsfileToBeInserted.getParentFile().getName());
       IoTDBDescriptor.getInstance().getConfig().setReadOnly(true);
       throw new TsFileProcessorException(e);
@@ -1259,8 +1260,9 @@ public class StorageGroupProcessor {
 
       // update latest time map
       updateLatestTimeMap(newTsFileResource);
-    } catch (TsFileProcessorException | DiskSpaceInsufficientException e) {
-      logger.error("Failed to append the tsfile {} to storage group processor {}.",
+    } catch (DiskSpaceInsufficientException e) {
+      logger.error(
+          "Failed to append the tsfile {} to storage group processor {} because the disk space is insufficient.",
           tsfileToBeInserted.getAbsolutePath(), tsfileToBeInserted.getParentFile().getName());
       IoTDBDescriptor.getInstance().getConfig().setReadOnly(true);
       throw new TsFileProcessorException(e);
@@ -1415,23 +1417,28 @@ public class StorageGroupProcessor {
     if (!targetFile.getParentFile().exists()) {
       targetFile.getParentFile().mkdirs();
     }
-    if (syncedTsFile.exists() && !targetFile.exists()) {
-      try {
-        FileUtils.moveFile(syncedTsFile, targetFile);
-      } catch (IOException e) {
-        throw new TsFileProcessorException(String.format(
-            "File renaming failed when loading tsfile. Origin: %s, Target: %s, because %s",
-            syncedTsFile.getAbsolutePath(), targetFile.getAbsolutePath(), e.getMessage()));
-      }
+    try {
+      FileUtils.moveFile(syncedTsFile, targetFile);
+    } catch (IOException e) {
+      logger.error("File renaming failed when loading tsfile. Origin: {}, Target: {}",
+          syncedTsFile.getAbsolutePath(), targetFile.getAbsolutePath(), e);
+      throw new TsFileProcessorException(String.format(
+          "File renaming failed when loading tsfile. Origin: %s, Target: %s, because %s",
+          syncedTsFile.getAbsolutePath(), targetFile.getAbsolutePath(), e.getMessage()));
     }
+    File syncedResourceFile = new File(
+        syncedTsFile.getAbsolutePath() + TsFileResource.RESOURCE_SUFFIX);
+    File targetResourceFile = new File(
+        targetFile.getAbsolutePath() + TsFileResource.RESOURCE_SUFFIX);
     try {
-      FileUtils.moveFile(new File(syncedTsFile.getAbsolutePath() + TsFileResource.RESOURCE_SUFFIX),
-          new File(targetFile.getAbsolutePath() + TsFileResource.RESOURCE_SUFFIX));
+      FileUtils.moveFile(syncedResourceFile, targetResourceFile);
     } catch (IOException e) {
+      logger.error("File renaming failed when loading .resource file. Origin: {}, Target: {}",
+          syncedResourceFile.getAbsolutePath(), targetResourceFile.getAbsolutePath(), e);
       throw new TsFileProcessorException(String.format(
           "File renaming failed when loading .resource file. Origin: %s, Target: %s, because %s",
-          new File(syncedTsFile + TsFileResource.RESOURCE_SUFFIX).getAbsolutePath(),
-          new File(targetFile + TsFileResource.RESOURCE_SUFFIX).getAbsolutePath(), e.getMessage()));
+          syncedResourceFile.getAbsolutePath(), targetResourceFile.getAbsolutePath(),
+          e.getMessage()));
     }
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
index be9d43e..45b1a32 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/QueryProcessExecutor.java
@@ -245,7 +245,7 @@ public class QueryProcessExecutor extends AbstractQueryProcessExecutor {
         MeasurementSchema schema = knownSchemas.get(chunkMetaData.getMeasurementUid());
         if (schema == null) {
           throw new MetadataException(String
-              .format("Can not get schema if measurement [%s]",
+              .format("Can not get the schema of measurement [%s]",
                   chunkMetaData.getMeasurementUid()));
         }
         checkPathExists(node, fullPath, schema, true);