This is an automated email from the ASF dual-hosted git repository.
spricoder pushed a commit to branch rel/1.0
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/1.0 by this push:
new 40619491be [IOTDB-5324] Fix wal cann't be deleted in destDataNode
after region migration when data_replication_factor is 1 in IoTConsensus
(#8836) (#8876)
40619491be is described below
commit 40619491beea1581482657350ab875c5b1bd8c41
Author: Potato <[email protected]>
AuthorDate: Fri Jan 13 19:11:23 2023 +0800
[IOTDB-5324] Fix wal cann't be deleted in destDataNode after region
migration when data_replication_factor is 1 in IoTConsensus (#8836) (#8876)
Signed-off-by: OneSizeFitQuorum <[email protected]>
Signed-off-by: OneSizeFitQuorum <[email protected]>
---
.../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);
+ }
+ }
}