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/11/10 07:52:04 UTC

(iotdb) branch check_iot_consensus_searchIndex updated (20834ea23cf -> dfeeab8079b)

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

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


 discard 20834ea23cf fix
     new dfeeab8079b fix

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (20834ea23cf)
            \
             N -- N -- N   refs/heads/check_iot_consensus_searchIndex (dfeeab8079b)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 .../java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


(iotdb) 01/01: fix

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

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

commit dfeeab8079b1b5f7a97c7513270432d5cb8d7127
Author: OneSizeFitQuorum <ta...@apache.org>
AuthorDate: Fri Nov 10 15:48:33 2023 +0800

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

diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
index 66b7ccd976a..910a12bd62b 100644
--- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
+++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java
@@ -143,11 +143,14 @@ public class IoTConsensusServerImpl {
     this.searchIndex = new AtomicLong(consensusReqReader.getCurrentSearchIndex());
     this.ioTConsensusServerMetrics = new IoTConsensusServerMetrics(this);
     this.logDispatcher = new LogDispatcher(this, clientManager);
+
     // 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();
+    // see message in logs for details
+    checkAndUpdateSearchIndex();
   }
 
   public IStateMachine getStateMachine() {
@@ -803,6 +806,27 @@ public class IoTConsensusServerImpl {
     }
   }
 
+  public void checkAndUpdateSearchIndex() {
+    long currentSearchIndex = searchIndex.get();
+    long safelyDeletedSearchIndex = getCurrentSafelyDeletedSearchIndex();
+    if (currentSearchIndex < safelyDeletedSearchIndex) {
+      logger.warn(
+          "When the node is restarted, the searchIndex({}) of the current region({}) is less than "
+              + "the safelyDeletedSearchIndex({}), which means that the data of the current region has not been flushed by the wal to disk,"
+              + " but has been synchronized to another node, and the different replicas are now inconsistent"
+              + " and cannot be automatically recovered. "
+              + "To prevent subsequent logs from marking smaller searchIndex and exacerbating the inconsistency, "
+              + "we manually set the searchIndex({}) to safelyDeletedSearchIndex({}) here to reduce the impact"
+              + " of this problem in the future",
+          currentSearchIndex,
+          consensusGroupId,
+          safelyDeletedSearchIndex,
+          currentSearchIndex,
+          safelyDeletedSearchIndex);
+      searchIndex.set(safelyDeletedSearchIndex);
+    }
+  }
+
   public TSStatus syncLog(int sourcePeerId, IConsensusRequest request) {
     return cacheQueueMap
         .computeIfAbsent(sourcePeerId, SyncLogCacheQueue::new)