iotdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qiaojia...@apache.org
Subject [iotdb] branch master updated: Update level compaction delete and change list lock (#2070)
Date Thu, 19 Nov 2020 00:59:29 GMT
This is an automated email from the ASF dual-hosted git repository.

qiaojialin 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 344c387  Update level compaction delete and change list lock (#2070)
344c387 is described below

commit 344c3875c4325c07bb14c0b2a95a9073714eb8cc
Author: zhanglingzhe0820 <445073309@qq.com>
AuthorDate: Thu Nov 19 08:56:04 2020 +0800

    Update level compaction delete and change list lock (#2070)
---
 .../level/LevelCompactionTsFileManagement.java     | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java
b/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java
index 3f36d0b..515ef6b 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/level/LevelCompactionTsFileManagement.java
@@ -83,13 +83,17 @@ public class LevelCompactionTsFileManagement extends TsFileManagement
{
     clear();
   }
 
-  private void deleteLevelFiles(long timePartitionId, Collection<TsFileResource> mergeTsFiles)
{
-    logger.debug("{} [compaction] merge starts to delete file", storageGroupName);
+  private void deleteLevelFilesInDisk(Collection<TsFileResource> mergeTsFiles) {
+    logger.debug("{} [compaction] merge starts to delete real file", storageGroupName);
     for (TsFileResource mergeTsFile : mergeTsFiles) {
       deleteLevelFile(mergeTsFile);
       logger
           .info("{} [Compaction] delete TsFile {}", storageGroupName, mergeTsFile.getTsFilePath());
     }
+  }
+
+  private void deleteLevelFilesInList(long timePartitionId, Collection<TsFileResource>
mergeTsFiles) {
+    logger.debug("{} [compaction] merge starts to delete file list", storageGroupName);
     for (int i = 0; i < seqLevelNum; i++) {
       if (sequenceTsFileResources.containsKey(timePartitionId)) {
         if (sequenceTsFileResources.get(timePartitionId).size() > i) {
@@ -338,12 +342,14 @@ public class LevelCompactionTsFileManagement extends TsFileManagement
{
             if (isSeq) {
               for (TreeSet<TsFileResource> currMergeFile : sequenceTsFileResources
                   .get(timePartition)) {
-                deleteLevelFiles(timePartition, currMergeFile);
+                deleteLevelFilesInDisk(currMergeFile);
+                deleteLevelFilesInList(timePartition, currMergeFile);
               }
             } else {
               for (List<TsFileResource> currMergeFile : unSequenceTsFileResources
                   .get(timePartition)) {
-                deleteLevelFiles(timePartition, currMergeFile);
+                deleteLevelFilesInDisk(currMergeFile);
+                deleteLevelFilesInList(timePartition, currMergeFile);
               }
             }
           }
@@ -369,13 +375,15 @@ public class LevelCompactionTsFileManagement extends TsFileManagement
{
                 CompactionUtils
                     .merge(targetResource, sourceTsFileResources, storageGroupName,
                         new CompactionLogger(storageGroupDir, storageGroupName), deviceSet,
true);
-                deleteLevelFiles(timePartition, sourceTsFileResources);
+                deleteLevelFilesInDisk(sourceTsFileResources);
+                deleteLevelFilesInList(timePartition, sourceTsFileResources);
                 sequenceTsFileResources.get(timePartition).get(level + 1).add(targetResource);
               } else {
                 CompactionUtils
                     .merge(targetResource, sourceTsFileResources, storageGroupName,
                         new CompactionLogger(storageGroupDir, storageGroupName), deviceSet,
false);
-                deleteLevelFiles(timePartition, sourceTsFileResources);
+                deleteLevelFilesInDisk(sourceTsFileResources);
+                deleteLevelFilesInList(timePartition, sourceTsFileResources);
                 unSequenceTsFileResources.get(timePartition).get(level + 1).add(targetResource);
               }
             }
@@ -491,19 +499,20 @@ public class LevelCompactionTsFileManagement extends TsFileManagement
{
                 storageGroupName, i, toMergeTsFiles.size());
             writeLock();
             try {
-              deleteLevelFiles(timePartition, toMergeTsFiles);
               compactionLogger.logMergeFinish();
               if (sequence) {
                 sequenceTsFileResources.get(timePartition).get(i + 1).add(newResource);
               } else {
                 unSequenceTsFileResources.get(timePartition).get(i + 1).add(newResource);
               }
+              deleteLevelFilesInList(timePartition, toMergeTsFiles);
               if (mergeResources.size() > i + 1) {
                 mergeResources.get(i + 1).add(newResource);
               }
             } finally {
               writeUnlock();
             }
+            deleteLevelFilesInDisk(toMergeTsFiles);
             compactionLogger.close();
             File logFile = FSFactoryProducer.getFSFactory()
                 .getFile(storageGroupDir, storageGroupName + COMPACTION_LOG_NAME);


Mime
View raw message