You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/07/20 14:40:43 UTC

[GitHub] [rocketmq] JanWarlen opened a new issue, #4644: ./mqadmin deleteTopic has an error

JanWarlen opened a new issue, #4644:
URL: https://github.com/apache/rocketmq/issues/4644

   
   **BUG REPORT**
   
   1. Please describe the issue you observed:
   
   - What did you do (The steps to reproduce)?
   - `./mqadmin deleteTopic  -n 'master:9876' -c DefaultCluster -t test_topic`
   
   - What is expected to see?
   - topic delete succeed
   
   - What did you see instead?
   - `org.apache.rocketmq.tools.command.SubCommandException: DeleteTopicSubCommand command failed
           at org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand.execute(DeleteTopicSubCommand.java:97)
           at org.apache.rocketmq.tools.command.MQAdminStartup.main0(MQAdminStartup.java:149)
           at org.apache.rocketmq.tools.command.MQAdminStartup.main(MQAdminStartup.java:100)
   Caused by: org.apache.rocketmq.client.exception.MQClientException: CODE: 1  DESC: Can't modify topic or subscription group from slave broker, please execute it from master broker.
   For more information, please visit the url, http://rocketmq.apache.org/docs/faq/
           at org.apache.rocketmq.client.impl.MQClientAPIImpl.deleteTopicInBroker(MQClientAPIImpl.java:1499)
           at org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.deleteTopicInBroker(DefaultMQAdminExtImpl.java:465)
           at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.deleteTopicInBroker(DefaultMQAdminExt.java:336)
           at org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand.deleteTopic(DeleteTopicSubCommand.java:44)
           at org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand.execute(DeleteTopicSubCommand.java:91)
           ... 2 more`
   
   2. Please tell us about your environment:
   I have 3 broker, one master, two slave.
   3 nameserver
   I can create topic by command `./mqadmin updateTopic -n master:9876 -c DefaultCluster -t test_topic`
   and i can delete topic by rocketmq-dashboard.but not work on command `./mqadmin deleteTopic`
   system is centos7_64
   rocketmq version: 4.9.4
   
   4. Other information (e.g. detailed explanation, logs, related issues, suggestions on how to fix, etc):
   i checked tools' code,and here is the question:
   first: code `org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand#deleteTopic`try to find all broker addrs by code `CommandUtil.fetchMasterAndSlaveAddrByClusterName`.
   second: when it ready to delete the topic,`org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl#deleteTopicInBroker`,it exec the command on every single broker, didn't void the slave.
   third: i add some `System.out.println`
   ```java
   public static void deleteTopic(final DefaultMQAdminExt adminExt,
           final String clusterName,
           final String topic
       ) throws InterruptedException, MQBrokerException, RemotingException, MQClientException {
   
           Set<String> brokerAddressSet = CommandUtil.fetchMasterAndSlaveAddrByClusterName(adminExt, clusterName);
           System.out.println("brokerAddressSet:"+ Arrays.toString(brokerAddressSet.toArray()));
           adminExt.deleteTopicInBroker(brokerAddressSet, topic);
           System.out.printf("delete topic [%s] from cluster [%s] success.%n", topic, clusterName);
   
           Set<String> nameServerSet = null;
           if (adminExt.getNamesrvAddr() != null) {
               String[] ns = adminExt.getNamesrvAddr().trim().split(";");
               nameServerSet = new HashSet(Arrays.asList(ns));
           }
   
           adminExt.deleteTopicInNameServer(nameServerSet, topic, clusterName);
           System.out.printf("delete topic [%s] from NameServer success.%n", topic);
       }
   ```
   ```java
   org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl#deleteTopicInBroker
   @Override
       public void deleteTopicInBroker(Set<String> addrs,
                                       String topic) throws RemotingException, MQBrokerException, InterruptedException,
               MQClientException {
           for (String addr : addrs) {
               System.out.println("org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.deleteTopicInBroker:" + addr);
               this.mqClientInstance.getMQClientAPIImpl().deleteTopicInBroker(addr, topic, timeoutMillis);
           }
       }
   ```
   and the last but also important,here is the log when i exec the delete command again:
   ```shell
   [root@master bin]# ./mqadmin deleteTopic -n 'master:9876' -c DefaultCluster -t test_topic
   brokerAddressSet:[192.168.125.201:10911, 192.168.125.202:10911, 192.168.125.203:10911]
   org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.deleteTopicInBroker:192.168.125.201:10911
   org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.deleteTopicInBroker:192.168.125.202:10911
   org.apache.rocketmq.tools.command.SubCommandException: DeleteTopicSubCommand command failed
           at org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand.execute(DeleteTopicSubCommand.java:97)
           at org.apache.rocketmq.tools.command.MQAdminStartup.main0(MQAdminStartup.java:149)
           at org.apache.rocketmq.tools.command.MQAdminStartup.main(MQAdminStartup.java:100)
   Caused by: org.apache.rocketmq.client.exception.MQClientException: CODE: 1  DESC: Can't modify topic or subscription group from slave broker, please execute it from master broker.
   For more information, please visit the url, http://rocketmq.apache.org/docs/faq/
           at org.apache.rocketmq.client.impl.MQClientAPIImpl.deleteTopicInBroker(MQClientAPIImpl.java:1499)
           at org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.deleteTopicInBroker(DefaultMQAdminExtImpl.java:465)
           at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.deleteTopicInBroker(DefaultMQAdminExt.java:336)
           at org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand.deleteTopic(DeleteTopicSubCommand.java:44)
           at org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand.execute(DeleteTopicSubCommand.java:91)
           ... 2 more
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on issue #4644: ./mqadmin deleteTopic has an error

Posted by GitBox <gi...@apache.org>.
RongtongJin commented on issue #4644:
URL: https://github.com/apache/rocketmq/issues/4644#issuecomment-1192076999

   Merged


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] JanWarlen commented on issue #4644: ./mqadmin deleteTopic has an error

Posted by GitBox <gi...@apache.org>.
JanWarlen commented on issue #4644:
URL: https://github.com/apache/rocketmq/issues/4644#issuecomment-1191362026

   > Good catch! I think there are two solutions:
   > 
   > 1. deleteTopic subCommand only operate master broker
   > 2. Remove the verification of slave in delete topic process in broker
   > 
   > I prefer the former
   > 
   > Could you submit a pull request to fix the issue?
   
   I create a pull request,but I change code on branch `4.9.x`, and follow the pull request guide **Make sure set the target branch to `develop`**.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] JanWarlen commented on issue #4644: ./mqadmin deleteTopic has an error

Posted by GitBox <gi...@apache.org>.
JanWarlen commented on issue #4644:
URL: https://github.com/apache/rocketmq/issues/4644#issuecomment-1190377624

   sorry about lost the broker exec code:
   ```java
   org.apache.rocketmq.broker.processor.AdminBrokerProcessor#deleteTopic
   private synchronized RemotingCommand deleteTopic(ChannelHandlerContext ctx,
           RemotingCommand request) throws RemotingCommandException {
           final RemotingCommand response = RemotingCommand.createResponseCommand(null);
           if (validateSlave(response)) {
               // TODO 有个bug,mqadmin deleteTopic 命令执行时始终失败,异常信息是这里返回的response
               //  但是使用arthas监听broker方法的返回值,response 的code是0-SUCCESS
               //  通过dashhboard 界面删除是正常的
   // here is the problem
               return response;
           }
           DeleteTopicRequestHeader requestHeader =
               (DeleteTopicRequestHeader) request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
   
           log.info("deleteTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
   
           String topic = requestHeader.getTopic();
           if (!TopicValidator.validateTopic(topic, response)) {
               return response;
           }
           if (TopicValidator.isSystemTopic(topic, response)) {
               return response;
           }
   
           if (MixAll.isLmq(topic)) {
               this.brokerController.getMessageStore().cleanUnusedLmqTopic(topic);
               response.setCode(ResponseCode.SUCCESS);
               response.setRemark(null);
               return response;
           }
   
           this.brokerController.getTopicConfigManager().deleteTopicConfig(topic);
           this.brokerController.getMessageStore()
               .cleanUnusedTopic(this.brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
           if (this.brokerController.getBrokerConfig().isAutoDeleteUnusedStats()) {
               this.brokerController.getBrokerStatsManager().onTopicDeleted(requestHeader.getTopic());
           }
           response.setCode(ResponseCode.SUCCESS);
           response.setRemark(null);
           return response;
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on issue #4644: ./mqadmin deleteTopic has an error

Posted by GitBox <gi...@apache.org>.
RongtongJin commented on issue #4644:
URL: https://github.com/apache/rocketmq/issues/4644#issuecomment-1190997868

   Good catch! I think there are two solutions:
   1. deleteTopic subCommand only operate master broker
   2. Remove the verification of slave in delete topic process in broker
   
   I prefer the former
   
   Could submit a pull request to fix the issue?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin closed issue #4644: ./mqadmin deleteTopic has an error

Posted by GitBox <gi...@apache.org>.
RongtongJin closed issue #4644: ./mqadmin deleteTopic has an error
URL: https://github.com/apache/rocketmq/issues/4644


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org