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] During the update of the NameServer, messages may be sent to the slave #1186

Open
gaoyf opened this issue Feb 18, 2025 · 0 comments
Open

Comments

@gaoyf
Copy link

gaoyf commented Feb 18, 2025

The issue tracker is ONLY used for the go client (feature request of RocketMQ need to follow RIP process). Keep in mind, please check whether there is an existing same report before your raise a new one.

Alternately (especially if your communication is not a bug report), you can send mail to our mailing lists. We welcome any friendly suggestions, bug fixes, collaboration, and other improvements.

Please ensure that your bug report is clear and that it is complete. Otherwise, we may be unable to understand it or to reproduce it, either of which would prevent us from fixing the bug. We strongly recommend the report(bug report or feature request) could include some hints as to the following:

BUG REPORT

  1. Please describe the issue you observed:

    • What did you do (The steps to reproduce)?
      在我更新NameServer期间,我发现某些消息被发送到了slave。我在分析了下面的代码后,发现了并发安全问题:

    Image
    上面两处更新代码应该具备原子性,不应该分开执行。
    假设在NameServer更新期间,存在如下几种路由信息的变化:

Image
假设GO客户端存在线程A和线程B,按如下顺序执行:

1 线程A执行UpdateTopicRouteInfo,获取路由状态1,此时路由及broker地址是可写的。

2 线程B执行UpdateTopicRouteInfo,获取路由状态2,此时broker的地址是slave,即不可写,接着线程B覆盖了线程A的结果。

3 线程B执行UpdatePublishInfo,缓存结果。

4 线程A执行UpdatePublishInfo,覆盖了线程B的结果。

注意:此时GO客户端执行p.publishInfo.Load(topic)获取的路由信息为可写,但是broker地址却是slave,那么发送消息时将会发送到slave,如下图:

Image
另外,java客户端这两块的逻辑就在同一把锁中执行,可以参考:

Image

- What did you expect to see?

在更新NameServer期间,消息不会发送到slave.
- What did you see instead?
在更新NameServer期间,消息可能会发送到slave.
2. Please tell us about your environment:

 - What is your OS?
 win
 - What is your client version?
 v2.1.1-rc2,最新版本也是如此
 - What is your RocketMQ version?
 5.1.1
  1. Other information (e.g. detailed explanation, logs, related issues, suggestions on how to fix, etc):

FEATURE REQUEST

  1. Please describe the feature you are requesting.

  2. Provide any additional detail on your proposed use case for this feature.

  3. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have). Are you currently using any workarounds to address this issue?

  4. If there are some sub-tasks using -[] for each subtask and create a corresponding issue to map to the sub task:

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

No branches or pull requests

1 participant