[Bug] mqadmin updateBrokerConfig -a false updates the slaves anyway

未关闭
#11,385 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@iloveeyjafjalla 已经在做这个了。

开始于 2026年10月13日。

  • #11386 来自 @iloveeyjafjalla —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
java
领域
cli

调研方向

The option parsing lives in the updateBrokerConfig subcommand of the tools module, where the a option is declared and checked with hasOption before choosing between the master-only and master-plus-slave address lists. Read how the argument value is obtained there and how the two CommandUtil fetch helpers are used. Done means -a false and a missing -a reach only masters, while -a true still reaches slaves; the mock-broker test that counts UPDATE_BROKER_CONFIG requests should confirm it. Pull request #11386 already targets this, so check it before starting.

由索引模型根据 Issue 内容生成。

描述

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

OS: any (mqadmin, tools module)

RocketMQ version

branch: develop
Git commit id: 9ea2ccdc2b41445aee5e177e14e501d606f5a1ed (the command is unchanged on develop@b76420599)

JDK Version

Compiler: Temurin 1.8.0_504 (target 1.8, same as CI)

Describe the Bug

mqadmin updateBrokerConfig -a false updates the slaves anyway.

The option is declared with the boolean as its argument, and the help says so:

opt = new Option("a", "updateAllBroker", true, "update all brokers include slave");
...
if (commandLine.hasOption('a')) {
    brokerAddrSet = CommandUtil.fetchMasterAndSlaveAddrByClusterName(defaultMQAdminExt, clusterName);
} else {
    brokerAddrSet = CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
}

getOptionValue('a') is never called, so any presence of the option — including the explicit -a false that the help's
<arg> invites — selects the master+slave fan-out. A user who wants to touch only the masters but spells the flag out gets
every broker in the cluster updated, which for role-sensitive keys (e.g. anything read at startup) means the slaves are
configured differently from what the operator asked for. Because the option requires an argument, there is also no way to ask
for "masters only" by writing the flag alone.

Steps to Reproduce
  1. mqadmin updateBrokerConfig -c <cluster> -a false -k <key> -v <value> -n <namesrv>.
  2. The UPDATE_BROKER_CONFIG request is sent to the slaves of the cluster as well (see the test below, which counts the
    requests each mock broker received: the slave receives one although the flag says false).
Expected behavior

-a false (and a missing -a) update the masters only; -a true updates the masters and the slaves, as the help text
describes.

Actual behavior

-a false behaves like -a/-a true: every broker of the cluster is updated.

Additional context

Fix: read the option's argument (Boolean.parseBoolean(commandLine.getOptionValue('a'))) instead of treating the option as a
switch. No documentation or script in the repository passes a bare -a, so the strict true|false argument stays as
documented.

主要语言
Java
星标
22.7k
派生
12k
平均合并
3 天 18 小时
30 天内合并 PR
17

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/rocketmq 的其他 Issue

查看 apache/rocketmq 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。