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:48:47 UTC
(iotdb) branch check_iot_consensus_searchIndex created (now dd8322a12bd)
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
at dd8322a12bd fix
This branch includes the following new commits:
new dd8322a12bd fix
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
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 dd8322a12bdbcd4391820bc3287331b39fa39c63
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..39a85ee22a2 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(
+ "The searchIndex({}) of the current region({}) is less than the safelyDeletedSearchIndex({}),"
+ + " which means that the data of the current node 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)