t8y2/dbx · error
topic stats not found: %s
Error message
topic stats not found: %s
What it means
This error means examineTopicStats successfully queried every master broker for the topic's stats (GetTopicStatsInfo), but the merged offset table came back empty. The library throws it because a topic that exists on the route should have at least one queue with offsets; an empty result means the topic effectively has no stats recorded on any broker (e.g. no queues ever created/used).
Source
Thrown at agents/drivers/rocketmq/topics.go:304
if requestErr != nil {
lastErr = requestErr
continue
}
partial, decodeErr := decodeTopicStats(response.Body)
if decodeErr != nil {
lastErr = decodeErr
continue
}
successCount++
for key, offset := range partial {
merged[key] = offset
}
}
if successCount != len(addresses) {
return nil, fmt.Errorf("query topic stats for %s on all masters: %w", topic, lastErr)
}
if len(merged) == 0 {
return nil, fmt.Errorf("topic stats not found: %s", topic)
}
return merged, nil
}
func decodeTopicStats(body []byte) (map[string]*admin.TopicOffset, error) {
var stats admin.TopicStatsTable
if err := json.Unmarshal(repairRocketMQJSON(body), &stats); err != nil {
return nil, fmt.Errorf("decode topic stats: %w", err)
}
if stats.OffsetTable == nil {
stats.OffsetTable = make(map[string]*admin.TopicOffset)
}
return stats.OffsetTable, nil
}
func masterAddressesFromRoute(route *admin.TopicRouteData) []string {
addresses := make(map[string]struct{})
for _, broker := range route.BrokerDatas {View on GitHub (pinned to c0390bff16)
Solutions
- Verify the topic actually has queues: check readQueueNums/writeQueueNums > 0 via getTopicConfig; if 0, use updatePartitions to provision queues first
- Confirm the topic name matches exactly (RocketMQ topics are case-sensitive and percent/char-sensitive)
- Check broker-side that the topic's offset table exists (consumer/producer has published or subscribed at least once)
- If the topic is intentionally empty, treat this error as 'no data' in the caller rather than retrying
Example fix
// before
stats, err := agent.getTopicStats(topic)
if err != nil { return err }
// after
stats, err := agent.getTopicStats(topic)
if err != nil {
if strings.Contains(err.Error(), "topic stats not found") {
return emptyStats(topic), nil // treat empty topic as zero-stats
}
return err
} Defensive patterns
Strategy: validation
Validate before calling
cfg, err := agent.getTopicConfig(topic)
if err != nil { return err }
if cfg.readQueueNums == 0 && cfg.writeQueueNums == 0 {
return fmt.Errorf("topic %s has no queues; stats will be empty", topic)
} Prevention
- Provision queues (updatePartitions) immediately after creating a topic
- Check queue nums > 0 before querying stats
- Treat 'topic stats not found' as an empty-result signal, not a retryable failure
When it happens
Trigger: examineTopicStats (via listProducers or getTopicStats) is called for a topic whose route resolves to master brokers, all brokers answer successfully, but every broker returns an empty offsetTable — typically a freshly created topic with readQueueNums/writeQueueNums of 0, or a topic whose queues were deleted.
Common situations: Querying stats for a topic that was created but never had queues provisioned; a topic auto-deleted after idle; callers listing stats across topics where some are empty stubs; name typos that still match a stale empty topic registration on the nameserver.
Related errors
- RocketMQ agent is not connected
- decode ACL list: %w
- query consumer status for group %s on all masters: %w
- decode consumer status: %w
- query consumer lag for group %s on all masters: %w
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/0a17fa71e72eb116.
Report an issue: GitHub.