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/01/13 01:47:44 UTC
[iotdb] branch master updated: [IOTDB-5324] Fix wal cann't be deleted in destDataNode after region migration when data_replication_factor is 1 in IoTConsensus (#8836)
This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 8383c48012 [IOTDB-5324] Fix wal cann't be deleted in destDataNode after region migration when data_replication_factor is 1 in IoTConsensus (#8836)
8383c48012 is described below
commit 8383c48012753553e0570e33146c88e03f64efda
Author: Potato <ta...@apache.org>
AuthorDate: Fri Jan 13 09:47:38 2023 +0800
[IOTDB-5324] Fix wal cann't be deleted in destDataNode after region migration when data_replication_factor is 1 in IoTConsensus (#8836)
Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
.../iotdb/consensus/iot/IoTConsensusServerImpl.java | 16 ++++++++++++----
1 file changed, 12 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 b36468d6c6..f8a4316db9 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
@@ -132,10 +132,7 @@ public class IoTConsensusServerImpl {
this.logDispatcher = new LogDispatcher(this, clientManager);
reader = (ConsensusReqReader) stateMachine.read(new GetConsensusReqReaderPlan());
long currentSearchIndex = reader.getCurrentSearchIndex();
- if (1 == configuration.size()) {
- // only one configuration means single replica.
- reader.setSafelyDeletedSearchIndex(Long.MAX_VALUE);
- }
+ checkAndUpdateSafeDeletedSearchIndex();
this.searchIndex = new AtomicLong(currentSearchIndex);
this.consensusGroupId = thisNode.getGroupId().toString();
this.metrics = new IoTConsensusServerMetrics(this);
@@ -606,6 +603,7 @@ public class IoTConsensusServerImpl {
logger.info("[IoTConsensus] log dispatcher to {} removed and cleanup", targetPeer);
// step 2, update configuration
configuration.remove(targetPeer);
+ checkAndUpdateSafeDeletedSearchIndex();
// step 3, persist configuration
persistConfigurationUpdate();
logger.info("[IoTConsensus] configuration updated to {}", this.configuration);
@@ -792,4 +790,14 @@ public class IoTConsensusServerImpl {
reader.setSafelyDeletedSearchIndex(searchIndex.get());
}
}
+
+ /**
+ * only one configuration means single replica, then we can set safelyDeletedSearchIndex to
+ * Long.MAX_VALUE.
+ */
+ public void checkAndUpdateSafeDeletedSearchIndex() {
+ if (configuration.size() == 1) {
+ reader.setSafelyDeletedSearchIndex(Long.MAX_VALUE);
+ }
+ }
}