You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/04/14 05:05:41 UTC

[iotdb] branch rel/0.13 updated: [To rel/0.13][IOTDB-2910] Fix Count aggregate is not right after delete sg bug (#5526)

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

qiaojialin pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.13 by this push:
     new 2509b9c46a [To rel/0.13][IOTDB-2910] Fix Count aggregate is not right after delete sg bug (#5526)
2509b9c46a is described below

commit 2509b9c46a1ba55dc66058487b6edec492d45d05
Author: Haonan <hh...@outlook.com>
AuthorDate: Thu Apr 14 13:05:35 2022 +0800

    [To rel/0.13][IOTDB-2910] Fix Count aggregate is not right after delete sg bug (#5526)
---
 .../db/integration/IoTDBDeleteStorageGroupIT.java  | 23 ++++++++++++++++++++++
 .../storagegroup/VirtualStorageGroupProcessor.java |  8 +++-----
 .../apache/iotdb/db/qp/executor/PlanExecutor.java  |  4 +++-
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeleteStorageGroupIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeleteStorageGroupIT.java
index a303b5bc33..ac5873b0b6 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeleteStorageGroupIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/IoTDBDeleteStorageGroupIT.java
@@ -157,4 +157,27 @@ public class IoTDBDeleteStorageGroupIT {
       assertEquals(0, result.size());
     }
   }
+
+  @Test
+  public void testDeleteStorageGroupAndThenQuery() throws Exception {
+    try (Connection connection = EnvFactory.getEnv().getConnection();
+        Statement statement = connection.createStatement()) {
+      statement.execute("insert into root.sg1.d1(time,s1) values(1,1);");
+      statement.execute("flush");
+      statement.execute("select count(*) from root.**;");
+      statement.execute("delete storage group root.sg1");
+      statement.execute("insert into root.sg1.sdhkajhd(time,s1) values(1,1);");
+      statement.execute("flush");
+      boolean hasResult = statement.execute("select count(*) from root.**");
+      assertTrue(hasResult);
+      int count = 0;
+      try (ResultSet resultSet = statement.getResultSet()) {
+        while (resultSet.next()) {
+          count++;
+          assertEquals(1, resultSet.getLong("count(root.sg1.sdhkajhd.s1)"));
+        }
+      }
+      assertEquals(1, count);
+    }
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
index 678477401f..5f3fc23774 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
@@ -25,8 +25,6 @@ import org.apache.iotdb.db.conf.IoTDBConstant;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.directories.DirectoryManager;
 import org.apache.iotdb.db.engine.StorageEngine;
-import org.apache.iotdb.db.engine.cache.ChunkCache;
-import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
 import org.apache.iotdb.db.engine.compaction.CompactionScheduler;
 import org.apache.iotdb.db.engine.compaction.CompactionTaskManager;
 import org.apache.iotdb.db.engine.compaction.task.CompactionRecoverManager;
@@ -121,6 +119,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import static org.apache.iotdb.db.conf.IoTDBConstant.FILE_NAME_SEPARATOR;
 import static org.apache.iotdb.db.engine.storagegroup.TsFileResource.TEMP_SUFFIX;
+import static org.apache.iotdb.db.qp.executor.PlanExecutor.operateClearCache;
 import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX;
 
 /**
@@ -2169,9 +2168,8 @@ public class VirtualStorageGroupProcessor {
             .recoverSettleFileMap
             .remove(oldTsFileResource.getTsFile().getAbsolutePath());
       }
-      // clear Cache , including chunk cache and timeseriesMetadata cache
-      ChunkCache.getInstance().clear();
-      TimeSeriesMetadataCache.getInstance().clear();
+      // clear Cache , including chunk cache, timeseriesMetadata cache and bloom filter cache
+      operateClearCache();
 
       // if old tsfile is being deleted in the process due to its all data's being deleted.
       if (!oldTsFileResource.getTsFile().exists()) {
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 75ad7e084e..a0571f71d3 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -31,6 +31,7 @@ import org.apache.iotdb.db.concurrent.ThreadName;
 import org.apache.iotdb.db.conf.IoTDBConstant;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.engine.StorageEngine;
+import org.apache.iotdb.db.engine.cache.BloomFilterCache;
 import org.apache.iotdb.db.engine.cache.ChunkCache;
 import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
 import org.apache.iotdb.db.engine.cq.ContinuousQueryService;
@@ -509,9 +510,10 @@ public class PlanExecutor implements IPlanExecutor {
     StorageEngine.getInstance().mergeAll();
   }
 
-  private void operateClearCache() {
+  public static void operateClearCache() {
     ChunkCache.getInstance().clear();
     TimeSeriesMetadataCache.getInstance().clear();
+    BloomFilterCache.getInstance().clear();
   }
 
   private void operateCreateSnapshot() {