{"record":{"id":"aa3cf1db99368ecd","repo":"t8y2/dbx","slug":"no-rocketmq-master-broker-found-for-topic-s-aa3cf1","errorCode":null,"errorMessage":"no RocketMQ master broker found for topic %s","messagePattern":"no RocketMQ master broker found for topic (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/topics.go","lineNumber":278,"sourceCode":"\t})\n\treturn map[string]any{\n\t\t\"name\": name, \"partitions\": len(partitionStats), \"replicationFactor\": 1,\n\t\t\"totalMessages\": total, \"partitionStats\": partitionStats,\n\t}, nil\n}\n\nfunc (a *rocketMQAgent) examineTopicStats(\n\tctx context.Context,\n\tclient *admin.Client,\n\ttopic string,\n) (map[string]*admin.TopicOffset, error) {\n\troute, err := client.ExamineTopicRouteInfo(ctx, topic)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\taddresses := masterAddressesFromRoute(route)\n\tif len(addresses) == 0 {\n\t\treturn nil, fmt.Errorf(\"no RocketMQ master broker found for topic %s\", topic)\n\t}\n\tmerged := make(map[string]*admin.TopicOffset)\n\tvar lastErr error\n\tsuccessCount := 0\n\tfor _, address := range addresses {\n\t\tresponse, requestErr := invokeRemotingWithClient(ctx, address,\n\t\t\tremoting.NewRequest(remoting.GetTopicStatsInfo, map[string]string{\"topic\": topic}))\n\t\tif requestErr != nil {\n\t\t\tlastErr = requestErr\n\t\t\tcontinue\n\t\t}\n\t\tpartial, decodeErr := decodeTopicStats(response.Body)\n\t\tif decodeErr != nil {\n\t\t\tlastErr = decodeErr\n\t\t\tcontinue\n\t\t}\n\t\tsuccessCount++\n\t\tfor key, offset := range partial {","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/topics.go#L260-L296","documentation":"examineTopicStats fetches the topic route and extracts master broker addresses; if the route contains no master addresses it cannot query stats and throws this error naming the topic. It means RocketMQ knows nothing usable about this topic's masters — typically the topic does not exist or has no readable broker assignments.","triggerScenarios":"Calling getTopicStats or listProducers for a topic whose route (ExamineTopicRouteInfo) returns no master broker addresses: nonexistent topic, topic with only slave/replica entries, or an empty route response.","commonSituations":"Typo in topic name; querying a topic on the wrong cluster/namespace; topic was deleted or autoCreateTopicEnable is off so it was never created; brokers not registered with the namesrv so the route is empty.","solutions":["Verify the topic exists: list topics or run mqadmin topicRoute -t <topic> against the same nameserver","Fix the topic name / cluster / namespace in the call","Create the topic if missing (mqadmin updateTopic or enable auto-create) and wait for route propagation","Check that brokers are up and registered with the nameserver so routes include masters"],"exampleFix":"// before\nstats, err := agent.Call(ctx, \"mq_get_topic_stats\", map[string]any{\"topic\":\"demo-topic\"})\n// after\n// create/verify the topic first, then retry\nstats, err := agent.Call(ctx, \"mq_get_topic_stats\", map[string]any{\"topic\":\"demo-topic\"})","handlingStrategy":"validation","validationCode":"// verify topic route has a master before asking for stats\nroute, err := client.ExamineTopicRouteInfo(ctx, topic)\nif err != nil {\n    return err\n}\nif len(masterAddressesFromRoute(route)) == 0 {\n    return fmt.Errorf(\"skip stats: no master for topic %s\", topic)\n}","typeGuard":null,"tryCatchPattern":"stats, err := getTopicStats(ctx, client, topic)\nif err != nil && strings.Contains(err.Error(), \"no RocketMQ master broker found\") {\n    // treat as topic-not-found: create topic or fix name, then retry\n}","preventionTips":["Confirm topic existence (mqadmin topicList) before stats calls","Double-check topic spelling, cluster and namespace in config","Enable auto-create or provision topics in deployment automation","Ensure brokers are registered with the nameserver before querying"],"tags":["rocketmq","topic","routing","not-found"],"backgroundTag":"topic-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}