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 2021/10/28 10:05:32 UTC

[GitHub] [rocketmq] Cczzzz opened a new issue #3439: BUG : mater and slave topic is not Inconsistent

Cczzzz opened a new issue #3439:
URL: https://github.com/apache/rocketmq/issues/3439


   master 和 slave 的topic 配置不一致 。
   in 4.9.1 ,on dledger.
   前提条件开启了 按版本注册。并且经历了选举(推测)
   发现时场景:
      测试时发现无法消费消息,但是可以发送消息。debug后发现由于是历史消息,选择slave 读取,返回了异常 topic 不存在。
   之后上服务器查询了topic 那个json 文件发现确实在slave 上不存在。
   
   我使用程序获取broker 的topicconfig :
   
      private static MQClientAPIImpl apiImpl;
   
       public static void main(String[] args) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQBrokerException, InterruptedException {
           ClientConfig clientConfig = new ClientConfig();
           clientConfig.setNamesrvAddr("10.xx.xx.244:9876");
           MQClientInstance instance = MQClientManager.getInstance().getOrCreateMQClientInstance(clientConfig, AclClient.getAclRPCHook());
           instance.start();
           apiImpl = instance.getMQClientAPIImpl();
           getAllTopicConfig("10.xx.xx.162:30911");
           getAllTopicConfig("10.xx.xx.116:30911");
           getAllTopicConfig("10.xx.xx.101:30911");
   
       }
   
       private static void getAllTopicConfig(String addr) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQBrokerException, InterruptedException {
           TopicConfigSerializeWrapper allTopicConfig = apiImpl.getAllTopicConfig(addr, 3000);
           System.out.println("-------------------" + addr + "-----------------");
           System.out.println("数量 : " + allTopicConfig.getTopicConfigTable().size());
           System.out.println("版本号 : " + allTopicConfig.getDataVersion().toString());
           // System.out.println(allTopicConfig.toJson());
       }
   
   
       public static class AclClient {
   
           private static final String ACL_ACCESS_KEY = "rocketmq_user";
   
           private static final String ACL_SECRET_KEY = "rocketmq_user";
   
           public static RPCHook getAclRPCHook() {
               return new AclClientRPCHook(new SessionCredentials(ACL_ACCESS_KEY, ACL_SECRET_KEY));
           }
       }
   
   结果如下:
   
   
   -------------------10.xx.xx.162:30911-----------------
   数量 : 991
   版本号 : DataVersion[timestamp=1635413476442, counter=1102]
   -------------------10.xx.xx.116:30911-----------------
   数量 : 911
   版本号 : DataVersion[timestamp=1635406971340, counter=1000]
   -------------------10.xx.xx.101:30911-----------------
   数量 : 907
   版本号 : DataVersion[timestamp=1635406972049, counter=996]
   
   
   之后去服务查看broker.log 
   没有打印 
   Update slave topic config from master
   Update slave consumer offset from master 
   等等几个定时任务,很奇怪。
   然后使用arthas  挂载broker 发现
   执行了
   watch *.SlaveSynchronize syncAll    方法
   却没有执行 
   watch *.BrokerOuterAPI  getAllTopicConfig   方法
   
   
     private void syncTopicConfig() {
           String masterAddrBak = this.masterAddr;
           if (masterAddrBak != null && !masterAddrBak.equals(brokerController.getBrokerAddr())) {
               try {
                   TopicConfigSerializeWrapper topicWrapper =
                       this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak);
                   if (!this.brokerController.getTopicConfigManager().getDataVersion()
                       .equals(topicWrapper.getDataVersion())) {
   
                       this.brokerController.getTopicConfigManager().getDataVersion()
                           .assignNewOne(topicWrapper.getDataVersion());
                       this.brokerController.getTopicConfigManager().getTopicConfigTable().clear();
                       this.brokerController.getTopicConfigManager().getTopicConfigTable()
                           .putAll(topicWrapper.getTopicConfigTable());
                       this.brokerController.getTopicConfigManager().persist();
   
                       log.info("Update slave topic config from master, {}", masterAddrBak);
                   }
               } catch (Exception e) {
                   log.error("SyncTopicConfig Exception, {}", masterAddrBak, e);
               }
           }
       }
   
   
   根据代码逻辑 怀疑  this.masterAddr  为 null。
   这在角色变成slave 是会被设置为null ,但当 上报nameserver 会修改为 正确的master 地址。
   但由于 #3381 的问题,可能没有将 masterAddr 设置为正确的 master 导致出现这个问题
   
   
   
   
   
   
   
   
   
   
   
   


-- 
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 #3439: BUG : mater and slave topic is not Inconsistent

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


   Merged #3442 


-- 
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 #3439: BUG : mater and slave topic is not Inconsistent

Posted by GitBox <gi...@apache.org>.
RongtongJin closed issue #3439:
URL: https://github.com/apache/rocketmq/issues/3439


   


-- 
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 #3439: BUG : mater and slave topic is not Inconsistent

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


   Merged #3442 


-- 
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 #3439: BUG : mater and slave topic is not Inconsistent

Posted by GitBox <gi...@apache.org>.
RongtongJin closed issue #3439:
URL: https://github.com/apache/rocketmq/issues/3439






-- 
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 #3439: BUG : mater and slave topic is not Inconsistent

Posted by GitBox <gi...@apache.org>.
RongtongJin closed issue #3439:
URL: https://github.com/apache/rocketmq/issues/3439


   


-- 
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 #3439: BUG : mater and slave topic is not Inconsistent

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






-- 
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