You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2023/04/28 03:15:21 UTC

[iotdb] branch jira5835 created (now 24e0ab59f4)

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

tanxinyu pushed a change to branch jira5835
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 24e0ab59f4 fix jira5835

This branch includes the following new commits:

     new 24e0ab59f4 fix jira5835

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: fix jira5835

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

tanxinyu pushed a commit to branch jira5835
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 24e0ab59f4507f05d6f11859b146a033489093cc
Author: OneSizeFitQuorum <ta...@apache.org>
AuthorDate: Fri Apr 28 11:14:13 2023 +0800

    fix jira5835
    
    Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
 .../apache/iotdb/consensus/iot/IoTConsensusServerImpl.java  | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java b/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
index 201322fa48..2d303f5a91 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
@@ -138,9 +138,12 @@ public class IoTConsensusServerImpl {
     this.config = config;
     this.logDispatcher = new LogDispatcher(this, clientManager);
     reader = (ConsensusReqReader) stateMachine.read(new GetConsensusReqReaderPlan());
-    long currentSearchIndex = reader.getCurrentSearchIndex();
+    this.searchIndex = new AtomicLong(reader.getCurrentSearchIndex());
+    // Since the underlying wal does not persist safelyDeletedSearchIndex, IoTConsensus needs to
+    // update wal with its syncIndex recovered from the consensus layer when initializing.
+    // This prevents wal from being piled up if the safelyDeletedSearchIndex is not updated after
+    // the restart and Leader migration occurs
     checkAndUpdateSafeDeletedSearchIndex();
-    this.searchIndex = new AtomicLong(currentSearchIndex);
     this.consensusGroupId = thisNode.getGroupId().toString();
     this.metrics = new IoTConsensusServerMetrics(this);
   }
@@ -817,12 +820,14 @@ public class IoTConsensusServerImpl {
   }
 
   /**
-   * only one configuration means single replica, then we can set safelyDeletedSearchIndex to
-   * Long.MAX_VALUE.
+   * If there is only one replica, set it to Long.MAX_VALUE.、 If there are multiple replicas, get
+   * the latest SafelyDeletedSearchIndex again. This enables wal to be deleted in a timely manner.
    */
   public void checkAndUpdateSafeDeletedSearchIndex() {
     if (configuration.size() == 1) {
       reader.setSafelyDeletedSearchIndex(Long.MAX_VALUE);
+    } else {
+      reader.setSafelyDeletedSearchIndex(getCurrentSafelyDeletedSearchIndex());
     }
   }