t8y2/dbx · error

no RocketMQ master broker found for topic %s

Error message

no RocketMQ master broker found for topic %s

What it means

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.

Source

Thrown at agents/drivers/rocketmq/topics.go:278

	})
	return map[string]any{
		"name": name, "partitions": len(partitionStats), "replicationFactor": 1,
		"totalMessages": total, "partitionStats": partitionStats,
	}, nil
}

func (a *rocketMQAgent) examineTopicStats(
	ctx context.Context,
	client *admin.Client,
	topic string,
) (map[string]*admin.TopicOffset, error) {
	route, err := client.ExamineTopicRouteInfo(ctx, topic)
	if err != nil {
		return nil, err
	}
	addresses := masterAddressesFromRoute(route)
	if len(addresses) == 0 {
		return nil, fmt.Errorf("no RocketMQ master broker found for topic %s", topic)
	}
	merged := make(map[string]*admin.TopicOffset)
	var lastErr error
	successCount := 0
	for _, address := range addresses {
		response, requestErr := invokeRemotingWithClient(ctx, address,
			remoting.NewRequest(remoting.GetTopicStatsInfo, map[string]string{"topic": topic}))
		if requestErr != nil {
			lastErr = requestErr
			continue
		}
		partial, decodeErr := decodeTopicStats(response.Body)
		if decodeErr != nil {
			lastErr = decodeErr
			continue
		}
		successCount++
		for key, offset := range partial {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Verify the topic exists: list topics or run mqadmin topicRoute -t <topic> against the same nameserver
  2. Fix the topic name / cluster / namespace in the call
  3. Create the topic if missing (mqadmin updateTopic or enable auto-create) and wait for route propagation
  4. Check that brokers are up and registered with the nameserver so routes include masters

Example fix

// before
stats, err := agent.Call(ctx, "mq_get_topic_stats", map[string]any{"topic":"demo-topic"})
// after
// create/verify the topic first, then retry
stats, err := agent.Call(ctx, "mq_get_topic_stats", map[string]any{"topic":"demo-topic"})
Defensive patterns

Strategy: validation

Validate before calling

// verify topic route has a master before asking for stats
route, err := client.ExamineTopicRouteInfo(ctx, topic)
if err != nil {
    return err
}
if len(masterAddressesFromRoute(route)) == 0 {
    return fmt.Errorf("skip stats: no master for topic %s", topic)
}

Try / catch

stats, err := getTopicStats(ctx, client, topic)
if err != nil && strings.Contains(err.Error(), "no RocketMQ master broker found") {
    // treat as topic-not-found: create topic or fix name, then retry
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/aa3cf1db99368ecd. Report an issue: GitHub.