CRZbulabula commented on code in PR #12078:
URL: https://github.com/apache/iotdb/pull/12078#discussion_r1501973364
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java:
##########
@@ -413,4 +413,10 @@ public void forceUpdateRegionPriority(
public void removeRegionRouteCache(TConsensusGroupId regionGroupId) {
loadCache.removeRegionRouteCache(regionGroupId);
}
+
+ /** Force balance the region leader. */
+ public void forceBalanceRegionLeader() {
+ routeBalancer.balanceRegionLeader();
+ routeBalancer.balanceRegionPriority();
Review Comment:
Please broadcast a RouteChangeEvent here, for which u can reference from
StatisticsService.updateLoadStatistics()
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java:
##########
@@ -74,12 +75,14 @@ public class RouteBalancer {
(CONF.isEnableAutoLeaderBalanceForRatisConsensus()
&&
ConsensusFactory.RATIS_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS))
|| (CONF.isEnableAutoLeaderBalanceForIoTConsensus()
- &&
ConsensusFactory.IOT_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS));
+ &&
ConsensusFactory.IOT_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS))
+ ||
ConsensusFactory.SIMPLE_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS);
Review Comment:
Add log: "The simple consensus protocol will always automatically designate
itself as the leader"
##########
iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java:
##########
@@ -596,6 +599,8 @@ private static int executeQuery(CliContext ctx,
IoTDBConnection connection, Stri
}
} else {
ctx.getPrinter().println("Msg: " + SUCCESS_MESSAGE);
+ long costTime = System.currentTimeMillis() - startTime;
+ logger.info("INSERT_FIRST: execute successfully, costTime: {}ms",
costTime);
Review Comment:
Remove useless logs.
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/LoadCache.java:
##########
@@ -545,10 +545,13 @@ public void waitForLeaderElection(List<TConsensusGroupId>
regionGroupIds) {
LOGGER.info("[RegionElection] Wait for leader election of RegionGroups:
{}", regionGroupIds);
while (System.currentTimeMillis() - startTime <=
LEADER_ELECTION_WAITING_TIMEOUT) {
AtomicBoolean allRegionLeaderElected = new AtomicBoolean(true);
+ LOGGER.info(
+ "[RegionElection] containsKey: {}",
+ regionRouteCacheMap.containsKey(regionGroupIds.get(0)));
Review Comment:
Remove useless logs
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java:
##########
@@ -184,6 +187,24 @@ private Map<TConsensusGroupId, Pair<Integer, Integer>>
balanceRegionLeader(
if (requestId.get() > 0) {
// Don't retry ChangeLeader request
AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNode(clientHandler);
+ for (int i = 0; i < requestId.get(); i++) {
+ if (clientHandler.getResponseMap().get(i).getCode()
+ == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ getLoadManager()
+ .forceUpdateRegionLeader(
+ clientHandler.getRequest(i).getRegionId(),
+
clientHandler.getRequest(i).getNewLeaderNode().getDataNodeId());
+ LOGGER.info(
+ "[forceUpdateRegionLeader], regionId:{}, datanodeId:{}",
+ clientHandler.getRequest(i).getRegionId(),
+ clientHandler.getRequest(i).getNewLeaderNode().getDataNodeId());
Review Comment:
Remove these logs after u broadcast the RouteChangeEvent. The observer will
log those successful leader change event.
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java:
##########
@@ -74,12 +75,14 @@ public class RouteBalancer {
(CONF.isEnableAutoLeaderBalanceForRatisConsensus()
&&
ConsensusFactory.RATIS_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS))
|| (CONF.isEnableAutoLeaderBalanceForIoTConsensus()
- &&
ConsensusFactory.IOT_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS));
+ &&
ConsensusFactory.IOT_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS))
+ ||
ConsensusFactory.SIMPLE_CONSENSUS.equals(DATA_REGION_CONSENSUS_PROTOCOL_CLASS);
private static final boolean IS_ENABLE_AUTO_LEADER_BALANCE_FOR_SCHEMA_REGION
=
(CONF.isEnableAutoLeaderBalanceForRatisConsensus()
&&
ConsensusFactory.RATIS_CONSENSUS.equals(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS))
|| (CONF.isEnableAutoLeaderBalanceForIoTConsensus()
- &&
ConsensusFactory.IOT_CONSENSUS.equals(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS));
+ &&
ConsensusFactory.IOT_CONSENSUS.equals(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS))
+ ||
ConsensusFactory.SIMPLE_CONSENSUS.equals(SCHEMA_REGION_CONSENSUS_PROTOCOL_CLASS);
Review Comment:
The same as above
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/route/RegionRouteCache.java:
##########
@@ -116,6 +121,7 @@ public boolean periodicUpdate() {
* @param leaderId Leader DataNodeId
*/
public void forceUpdateRegionLeader(int leaderId) {
+ LOGGER.info("[RegionElection], setLeaderId2: {}", leaderId);
Review Comment:
Remove useless logs
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/route/RegionRouteCache.java:
##########
@@ -98,6 +102,7 @@ public boolean periodicUpdate() {
// The leader of simple and ratis consensus is self-elected
if (leaderSample.get().getRight() != leaderId.get()) {
leaderId.set(leaderSample.get().getRight());
+ LOGGER.info("[RegionElection], setLeaderId1: {}",
leaderSample.get().getRight());
Review Comment:
Remove useless logs
##########
iotdb-core/confignode/src/test/resources/confignode1conf/iotdb-common.properties:
##########
@@ -18,10 +18,10 @@
#
timestamp_precision=ms
-data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
-schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
-schema_replication_factor=3
-data_replication_factor=3
+data_region_consensus_protocol_class=org.apache.iotdb.consensus.simple.SimpleConsensus
+schema_region_consensus_protocol_class=org.apache.iotdb.consensus.simple.SimpleConsensus
+schema_replication_factor=1
+data_replication_factor=1
Review Comment:
Don't forget to change them back
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/route/RegionRouteCache.java:
##########
@@ -128,6 +134,16 @@ public void forceUpdateRegionPriority(TRegionReplicaSet
regionPriority) {
this.regionPriority.set(regionPriority);
}
+ public boolean isRegionGroupUnready(boolean isDebug) {
+ if (isDebug) {
+ LOGGER.info(
+ "[RegionElection], isRegionGroupUnready: {}, {}",
+ unReadyLeaderId == leaderId.get(),
+ unReadyRegionPriority.equals(regionPriority.get()));
+ }
Review Comment:
Remove useless logs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]