Skip to content

[Bug] AutoBatch bug when connecting multiple RocketMQ clusters. #8806

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

Closed
3 tasks done
luozongle01 opened this issue Oct 10, 2024 · 2 comments · Fixed by #8807
Closed
3 tasks done

[Bug] AutoBatch bug when connecting multiple RocketMQ clusters. #8806

luozongle01 opened this issue Oct 10, 2024 · 2 comments · Fixed by #8807

Comments

@luozongle01
Copy link
Contributor

luozongle01 commented Oct 10, 2024

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

jdk 1.8

Describe the Bug

If multiple RocketMQ clusters are connected and autoBatch is enabled, messages may be sent to the wrong cluster if multiple clusters happen to have the same theme.

Steps to Reproduce

If I connect to multiple RocketMQ clusters on the same client and enable autoBatch, the topic name happens to be the same.
image

Messages may be sent to the wrong cluster
image

What Did You Expect to See?

The message should be sent to the correct cluster

What Did You See Instead?

When creating a Default MQProducer on the client side, an internal Producer Accumulator is initialized
Put the information into the accumulator table map, where key is the client ID and value is the created Producer Accumulator.
When initializing, it will first determine whether the Producer Accumulator has been created based on the client ID. But at this time, the user has not had the opportunity to set InstanceName or UnitName. So at this point, the client IDs within the same service are all the same.
So currently, multiple Default MQProducers created on the same client internally use the same produceAccumulator.
If the topic names of different clusters happen to be the same, it will be sent to the wrong cluster.

Additional Context

No response

@humkum
Copy link
Contributor

humkum commented Oct 10, 2024

You should set different instanceName for different producers in this situation.

@luozongle01
Copy link
Contributor Author

在这种情况下,您应该为不同的生产者设置不同的instanceName。

设置不同的instanceName也不行,因为创建DefaultMQProducer的时候直接把ProduceAccumulator也给创建了,这时候还没执行到设置unitName或者instanceName的代码。😂😂😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants