You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "mxsm (via GitHub)" <gi...@apache.org> on 2023/03/16 01:49:54 UTC

[GitHub] [rocketmq] mxsm commented on a diff in pull request #6359: [ISSUE #6358]Add chinese docs about persistent-unique-broker-id

mxsm commented on code in PR #6359:
URL: https://github.com/apache/rocketmq/pull/6359#discussion_r1137991012


##########
docs/cn/controller/persistent_unique_broker_id.md:
##########
@@ -0,0 +1,207 @@
+# 持久化的唯一BrokerId
+
+## 现阶段问题
+现在采用`BrokerAddress`作为Broker在Controller模式下的唯一标识。导致如下情景出现问题:
+
+- 容器环境下,每次Broker的重启或升级都可能会导致IP发生变化,导致之前的`BrokerAddress`留下的记录没办法和重启后的Broker联系起来,比如说`ReplicaInfo`, `SyncStateSet`等数据。
+## 改进方案
+在Controller侧采用`BrokerName:BrokerId`作为唯一标识,不再以`BrokerAddress`作为唯一标识。并且需要对`BrokerId`进行持久化存储,由于`ClusterName`和`BrokerName`都是启动的时候在配置文件中配置好的,所以只需要处理`BrokerId`的分配和持久化问题。
+Broker第一次上线的时候,只有配置文件中配置的`ClusterName`和`BrokerName`,以及自身的`BrokerAddress`。那么我们需要和`Controller`协商出一个在整个集群生命周期中都唯一确定的标识:`BrokerId`,该`BrokerId`从1开始分配。当Broker被选为Master的时候,它会在Name Server中重新注册,此时为了兼容之前的无HA的Master-Slave架构,那么需要在这一步暂时更改为`BrokerId`为0(之前的逻辑里面id为0代表着Broker是Master身份)。
+### 上线流程
+
+![](../image/controller/persistent_unique_broker_id/register_process.png)
+
+#### 1. GetNextBrokerId Request
+这时候发起一个`GetNextBrokerId`的请求到Controller,为了拿到当前的下一个待分配的`BrokerId`(从1开始分配)。
+#### 1.1 ReadFromDLedger
+此时Controller接收到请求,然后走DLedger去获取到状态机的`NextBrokerId`数据。
+#### 2. GetNextBrokerId Response
+Controller将`NextBrokerId`返回给Broker。
+#### 2.1, 2.2 CreateTempMetaFile
+Broker拿到`NextBrokerId`之后,创建一个临时文件`.broker.meta.temp`,里面记录了`NextBrokerId`(也就是期望应用的`BrokerId`),以及自己生成一个`RegisterCode`(用于之后的身份校验)也持久化到临时文件中。

Review Comment:
   需要删除2.2



##########
docs/cn/image/controller/persistent_unique_broker_id/test_1.png:
##########


Review Comment:
   这个图是否可以重新截图整理



##########
docs/cn/image/controller/persistent_unique_broker_id/test_12.png:
##########


Review Comment:
   这个图是否可以重新截图整理



##########
docs/cn/image/controller/persistent_unique_broker_id/test_13.png:
##########


Review Comment:
   这个图是否可以重新截图整理



##########
docs/cn/image/controller/persistent_unique_broker_id/normal_restart.png:
##########


Review Comment:
   这个图能否重新处理一下



##########
docs/cn/image/controller/persistent_unique_broker_id/test_10.png:
##########


Review Comment:
   这个图是否可以重新截图整理



##########
docs/cn/image/controller/persistent_unique_broker_id/test_14.png:
##########


Review Comment:
   这个图是否可以重新截图整理



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org