clsuterList command get wrong result when different cluster with same name server and same brokerName

- firstly, create broker-a.properties
brokerClusterName=DefaultCluster brokerName=broker-a brokerId=0 deleteWhen=04 fileReservedTime=48 listenPort=10911 namesrvAddr=localhost:9876 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH
startup with broker-a.properties, we can see the right output.
- secondly, create broker-b.properties brokerClusterName=DefaultCluster1 brokerName=broker-a brokerId=0 deleteWhen=04 fileReservedTime=48 listenPort=10921 namesrvAddr=localhost:9876 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH storePathRootDir=~/rocketmq/data/store storePathCommitLog=~/rocketmq/data/store/commitlog storePathIndex=~/rocketmq/data/store/index storePathConsumeQueue=~/rocketmq/data/store/consumequeue
then ClusterList give two broker both with 10921 port
Furthormore, under this situation, I create the topic to DefaultCluster1, the topic would be created to DefaultCluster.

@superheizai plz check your brokerId config in broker.conf is right.
I have named different cluster name for these two broker with same brokerId. Do you mean even in different cluster, they should be with different brokerId?
@duhenglucky This could be a bug. In the first picture, which show the same IP:port in different cluster. As I think, this could't happen at any case.
在nameServer中,一个broker名字对应一个BrokerData,BrokerData拥有一个clusterName private final HashMap<String/* brokerName */, BrokerData> brokerAddrTable; 所以你要改名 @superheizai
@CodeIngL , I know how to resolve the problem. What I want to know is if this result is RocketMQ wanted, or if this is a bug.
请看BrokerData应该可以非常简单理解设计。 @superheizai
This is an interesting issue. I suppose we need more discussion on it.
Since we use brokerName as the key of brokerAddrTable:
private final HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
if two clusters have brokers with the same brokerName, when broker registers itself to nameserver, it will overwrite previous one and the previous one will overwrite it again by next registration. So the brokerAddrTable of namesever is uncertain and that is the reason the topic was created onto the cluster you didn't want.
IMO, the questions @superheizai raised MAY need to be enhanced though we can avoid it by setting totally different brokerNames for different clusters like below:
1.
brokerClusterName=DefaultCluster
brokerName=broker-a
2.
brokerClusterName=DefaultCluster
brokerName=broker-b
3.
brokerClusterName=DefaultCluster1
brokerName=broker-c
4.
brokerClusterName=DefaultCluster1
brokerName=broker-d
@zongtanghu @duhenglucky What do u think?
This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.
This issue was closed because it has been inactive for 3 days since being marked as stale.