jt2594838 commented on code in PR #18769:
URL: https://github.com/apache/iotdb/pull/18769#discussion_r4131696421


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/consensus/ConsensusPrefetchingQueue.java:
##########
@@ -3369,11 +3369,39 @@ private boolean 
commitWithoutOutstandingAndRefreshWalRetention(
     return committed;
   }
 
+  private long getRequiredRetainedMinVersionId() {
+    // Committed progress can advance on another consumer or replica while 
this queue is still
+    // replaying an older local search index. Keep both boundaries so WAL 
deletion can never pass
+    // the earliest entry this queue has not inspected yet.
+    return Math.min(getCommittedRetainedMinVersionId(), 
getReplayRetainedMinVersionId());
+  }
+
   private long getCommittedRetainedMinVersionId() {
     refreshCommittedWalRetentionBound();
     return committedRetainedMinVersionId;
   }
 
+  private long getReplayRetainedMinVersionId() {
+    if (!(consensusReqReader instanceof WALNode)) {
+      return 0L;
+    }
+    final WALNode walNode = (WALNode) consensusReqReader;
+    return findReplayRetainedMinVersionId(
+        WALFileUtils.listAllWALFiles(walNode.getLogDirectory()), 
nextExpectedSearchIndex.get());

Review Comment:
   May use the cached WAL files in WALNode.



-- 
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