From 21511da384dea69b734ca1d5a3bd5c84267ecea2 Mon Sep 17 00:00:00 2001 From: rongtongjin <794220751@qq.com> Date: Fri, 20 Sep 2019 13:43:53 +0800 Subject: [PATCH] fix(broker):fix the issue that master node route info is lost when some node join the group in dledger mode Since brokerId defaults to 0, it will register with nameserver before brokerId is changed when broker restart, causing the route info of master to be overwritten. Set brokerId defaults to -1 in dledger mode and do not register wtih nameserver until brokerId is changed. Close #1464 --- .../java/org/apache/rocketmq/broker/BrokerController.java | 5 +---- .../main/java/org/apache/rocketmq/broker/BrokerStartup.java | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java index a885cd08..9bc154fd 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java @@ -857,12 +857,9 @@ public class BrokerController { if (!messageStoreConfig.isEnableDLegerCommitLog()) { startProcessorByHa(messageStoreConfig.getBrokerRole()); handleSlaveSynchronize(messageStoreConfig.getBrokerRole()); + this.registerBrokerAll(true, false, true); } - - - this.registerBrokerAll(true, false, true); - this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java index 4b986c0d..960b8484 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java @@ -178,6 +178,10 @@ public class BrokerStartup { break; } + if (messageStoreConfig.isEnableDLegerCommitLog()) { + brokerConfig.setBrokerId(-1); + } + messageStoreConfig.setHaListenPort(nettyServerConfig.getListenPort() + 1); LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator configurator = new JoranConfigurator(); -- GitLab