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

[iotdb] branch IOTDB-2910 created (now 459d535dbf)

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

haonan pushed a change to branch IOTDB-2910
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 459d535dbf [To rel/0.13][IOTDB-2910] Fix Count aggregate is not right after delete sg bug

This branch includes the following new commits:

     new 459d535dbf [To rel/0.13][IOTDB-2910] Fix Count aggregate is not right after delete sg bug

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: [To rel/0.13][IOTDB-2910] Fix Count aggregate is not right after delete sg bug

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch IOTDB-2910
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 459d535dbf6875bb3551d17a5a507b565fd9ba00
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu Apr 14 11:35:47 2022 +0800

    [To rel/0.13][IOTDB-2910] Fix Count aggregate is not right after delete sg bug
---
 .../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() {