HeimingZ commented on code in PR #11682:
URL: https://github.com/apache/iotdb/pull/11682#discussion_r1423610935


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/node/WALNode.java:
##########
@@ -583,22 +578,28 @@ private void snapshotMemTable(DataRegion dataRegion, File 
tsFile, MemTableInfo m
       }
     }
 
-    public long initFirstValidWALVersionId() {
-      long firstVersionId = checkpointManager.getFirstValidWALVersionId();
-      // This means that the relevant memTable in the file has been 
successfully flushed, so we
-      // should scroll through a new wal file so that the current file can be 
deleted
-      if (firstVersionId == Long.MIN_VALUE) {
-        // roll wal log writer to delete current wal file
-        if (buffer.getCurrentWALFileSize() > 0) {
-          rollWALFile();
-        }
-        // update firstValidVersionId
-        firstVersionId = checkpointManager.getFirstValidWALVersionId();
-        if (firstVersionId == Long.MIN_VALUE) {
-          firstVersionId = buffer.getCurrentWALFileVersion();
+    public boolean isContainsActiveOrPinnedMemTable(Long versionId) {
+      Set<Long> memTableIdsOfCurrentWal = memTableIdsOfWalMap.get(versionId);
+      // If this set is empty, there is a case where WalEntry has been logged 
but not persisted,
+      // because WalEntry is persisted asynchronously. In this case, the file 
cannot be deleted
+      // directly, so it is considered active
+      if (memTableIdsOfCurrentWal.isEmpty()) {
+        return true;
+      }
+      for (MemTableInfo memTableInfo : activeOrPinnedMemTables) {
+        for (Long memTableId : memTableIdsOfCurrentWal) {
+          if (memTableId.equals(memTableInfo.getMemTableId())) {
+            return true;
+          }
         }
       }

Review Comment:
   May we use Collections.disjoint() here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to