...
 
Commits (2)
    https://gitcode.net/apache/iotdb/-/commit/ba778c6a8642aed8d616472e2d0f4b53bd76c78e fix ratis remove peer not detected correctly by ConfigNode 2023-08-16T14:49:52+08:00 Jinrui.Zhang xingtanzjr@gmail.com https://gitcode.net/apache/iotdb/-/commit/3db15a82d27d9f7b37b8faa1b27129f0f7c6e447 pick last node to remove 2023-08-16T18:44:15+08:00 OneSizeFitQuorum tanxinyu@apache.org Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:tanxinyu@apache.org" title="tanxinyu@apache.org"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:tanxinyu@apache.org" title="tanxinyu@apache.org">OneSizeFitQuorum</a> &lt;<a href="mailto:tanxinyu@apache.org" title="tanxinyu@apache.org">tanxinyu@apache.org</a>&gt;</span>
......@@ -48,6 +48,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
......@@ -58,6 +59,7 @@ import static org.apache.iotdb.consensus.ConsensusFactory.IOT_CONSENSUS;
import static org.apache.iotdb.consensus.ConsensusFactory.SIMPLE_CONSENSUS;
public class DataNodeRemoveHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(DataNodeRemoveHandler.class);
private static final ConfigNodeConfig CONF = ConfigNodeDescriptor.getInstance().getConf();
......@@ -405,7 +407,7 @@ public class DataNodeRemoveHandler {
return configManager.getNodeManager().filterDataNodeThroughStatus(NodeStatus.Running).stream()
.map(TDataNodeConfiguration::getLocation)
.filter(e -> !regionReplicaNodes.contains(e))
.findAny();
.max(Comparator.comparingInt(TDataNodeLocation::getDataNodeId));
}
private boolean isSucceed(TSStatus status) {
......
......@@ -48,7 +48,6 @@ import org.apache.iotdb.consensus.exception.ConsensusException;
import org.apache.iotdb.consensus.exception.ConsensusGroupNotExistException;
import org.apache.iotdb.consensus.exception.NodeReadOnlyException;
import org.apache.iotdb.consensus.exception.PeerAlreadyInConsensusGroupException;
import org.apache.iotdb.consensus.exception.PeerNotInConsensusGroupException;
import org.apache.iotdb.consensus.exception.RatisRequestFailedException;
import org.apache.iotdb.consensus.exception.RatisUnderRecoveryException;
import org.apache.iotdb.consensus.ratis.metrics.RatisMetricSet;
......@@ -497,7 +496,9 @@ class RatisConsensus implements IConsensus {
}
// pre-condition: peer is a member of groupId
if (!group.getPeers().contains(peerToRemove)) {
return failed(new PeerNotInConsensusGroupException(groupId, myself));
logger.error("duplicated peer remove operation detected. {}-{}", groupId, peer);
return ConsensusGenericResponse.newBuilder().setSuccess(true).build();
// return failed(new PeerNotInConsensusGroupException(groupId, myself));
}
// update group peer information
......