apache / rocketmq

Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
https://rocketmq.apache.org/
Apache License 2.0
21.23k stars 11.68k forks source link

[Bug] the topicRouter is not updated when delete topic in broker #7884

Closed 1782935682 closed 8 months ago

1782935682 commented 8 months ago

Before Creating the Bug Report

Runtime platform environment

1

RocketMQ version

release-5.2.0

JDK Version

1.8

Describe the Bug

The topicRouter is not updated when I delete a topic in the broker

org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl#deleteTopicInBroker

image image

Steps to Reproduce

  1. create topic
  2. delete topic in broker
  3. query topic router

What Did You Expect to See?

the topicRouter shoud be updated when delete topic in broker

What Did You See Instead?

1

Additional Context

No response

xzwb commented 8 months ago

How do you create and delete topics? dashboard or mqadmin or sdk? I want to try to reproduce this issue

1782935682 commented 8 months ago

How do you create and delete topics? dashboard or mqadmin or sdk? I want to try to reproduce this issue

1.create with dashboard,create topic on cluster

image

2.use sdk , delete topic in one broker

org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl#deleteTopicInBroker;

    DefaultMQAdminExt mqAdminExt = new DefaultMQAdminExt(new AclClientRPCHook(new SessionCredentials("ak", "sk")), 20000);
    String name = UUID.randomUUID().toString();
    mqAdminExt.setInstanceName(name);
    mqAdminExt.setNamesrvAddr(DEFAULT_NAMESRVADDR);
    mqAdminExt.start();
    System.out.println("delete before");
    System.out.println("topicRouter" + ": " + JSON.toJSONString(mqAdminExt.examineTopicRouteInfo(TOPIC), true));
    mqAdminExt.deleteTopicInBroker(Collections.singleton(broker01), TOPIC);
    System.out.println("delete after");
    System.out.println("topicRouter" + ": " + JSON.toJSONString(mqAdminExt.examineTopicRouteInfo(TOPIC), true));
xzwb commented 8 months ago

i reproduce this issue, but i find when I restart my broker this topic has been deleted, i guess broker have some schedule to delete topic

yes rocketmq delete topic Only the topic data in memory will be deleted

protected TopicConfig removeTopicConfig(String topicName) {
        return this.topicConfigTable.remove(topicName);
    }

TopicQueueMappingDetail old = this.topicQueueMappingTable.remove(topic);
leizhiyuan commented 8 months ago

你需要继续调用 deleteTopicInNameServer

1782935682 commented 8 months ago

会删除topic全部路由,不能删除指定broker的路由

LC}MTF47V)}W20S 0 1$C{I

leizhiyuan commented 8 months ago

如果你只是要在一个broker删除,删除之后,等一会,broker会向ns注册,然后再查询。

leizhiyuan commented 8 months ago

你这个问题,还可以通过打开

在broker打开,enableSingleTopicRegister这个配置。 在ns 打开deleteTopicWithBrokerRegistration 这个配置来解决。可以看下这块代码。