Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] There may be thread safety issues with the brokerVersions Table and brokerAddrTable in MQClientInstance. #8743

Open
3 tasks done
luozongle01 opened this issue Sep 24, 2024 · 0 comments · May be fixed by #8744
Open
3 tasks done

Comments

@luozongle01
Copy link
Contributor

Before Creating the Bug Report

  • I found a bug, not just asking a question, which should be created in GitHub Discussions.

  • I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.

  • 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.
image

Although the brokerAddrTable always replaces the map inside, would it also be better to use Concurrent HashMap.
image

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

luozongle01 added a commit to luozongle01/rocketmq that referenced this issue Sep 24, 2024
… in MQClientInstance to Concurrent HashMap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant