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 95708409a01 [RatisConsensus] Use empty map for create peer (#12463)
95708409a01 is described below

commit 95708409a01591630307538618755723cc106ef4
Author: William Song <[email protected]>
AuthorDate: Sat May 18 00:01:10 2024 +0800

    [RatisConsensus] Use empty map for create peer (#12463)
    
    * address review issues
    
    * use empty list for createPeer in data region
    
    * haha
---
 .../thrift/impl/DataNodeInternalRPCServiceImpl.java   | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
index a46158aafb0..c575ca0781d 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
@@ -53,6 +53,7 @@ import 
org.apache.iotdb.commons.subscription.meta.topic.TopicMeta;
 import org.apache.iotdb.commons.trigger.TriggerInformation;
 import org.apache.iotdb.commons.udf.UDFInformation;
 import org.apache.iotdb.commons.udf.service.UDFManagementService;
+import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.consensus.common.Peer;
 import org.apache.iotdb.consensus.exception.ConsensusException;
 import 
org.apache.iotdb.consensus.exception.ConsensusGroupAlreadyExistException;
@@ -2155,9 +2156,23 @@ public class DataNodeInternalRPCServiceImpl implements 
IDataNodeRPCService.Iface
     TSStatus status = new 
TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
     try {
       if (regionId instanceof DataRegionId) {
-        DataRegionConsensusImpl.getInstance().createLocalPeer(regionId, peers);
+        // RatisConsensus requires an empty peer list during region transition
+        final List<Peer> createPeers =
+            ConsensusFactory.RATIS_CONSENSUS.equals(
+                    
IoTDBDescriptor.getInstance().getConfig().getDataRegionConsensusProtocolClass())
+                ? Collections.emptyList()
+                : peers;
+        DataRegionConsensusImpl.getInstance().createLocalPeer(regionId, 
createPeers);
       } else {
-        SchemaRegionConsensusImpl.getInstance().createLocalPeer(regionId, 
peers);
+        // RatisConsensus requires an empty peer list during region transition
+        final List<Peer> createPeers =
+            ConsensusFactory.RATIS_CONSENSUS.equals(
+                    IoTDBDescriptor.getInstance()
+                        .getConfig()
+                        .getSchemaRegionConsensusProtocolClass())
+                ? Collections.emptyList()
+                : peers;
+        SchemaRegionConsensusImpl.getInstance().createLocalPeer(regionId, 
createPeers);
       }
     } catch (ConsensusException e) {
       if (!(e instanceof ConsensusGroupAlreadyExistException)) {

Reply via email to