[Bug] There may be thread safety issues with the brokerVersions Table and brokerAddrTable in MQClientInstance.
Before Creating the Bug Report
-
[X] I found a bug, not just asking a question, which should be created in GitHub Discussions.
-
[X] I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
-
[X] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
macos: 11.7.10
RocketMQ version
5.3.0
JDK Version
JDK1.8
Describe the Bug
There may be concurrency issues with the value "HashMap<String, Integer>" in the brokerVersionTable of MQClientInstance, such as when a new broker node is added and other threads are getting or traversing the map. Although the likelihood of this happening is relatively low, there is indeed a risk involved.
Although the brokerAddrTable always replaces the map inside, would it also be better to use Concurrent HashMap.
Steps to Reproduce
If a new broker is added, when the client obtains the broker version number by sending a heartbeat and puts it into the brokerVersionTable, there may be exceptions if other threads are querying the brokerVersionTable.
What Did You Expect to See?
When adding a broker, both the brokerVersionTable and brokerAddrTable are thread safe
What Did You See Instead?
There may be thread safety issues with brokerVersionTable and brokerAddrTable
Additional Context
No response