{"record":{"id":"62932c3b1dd6f687","repo":"t8y2/dbx","slug":"no-rocketmq-master-broker-found","errorCode":null,"errorMessage":"no RocketMQ master broker found","messagePattern":"no RocketMQ master broker found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"agents/drivers/rocketmq/topics.go","lineNumber":444,"sourceCode":"\taddresses := make([]string, 0)\n\tfor _, name := range sortedKeys(info.BrokerAddrTable) {\n\t\tif brokerName != \"\" && brokerName != name {\n\t\t\tcontinue\n\t\t}\n\t\tif address := info.BrokerAddrTable[name].BrokerAddrs[\"0\"]; address != \"\" {\n\t\t\taddresses = append(addresses, address)\n\t\t}\n\t}\n\tif len(addresses) == 0 {\n\t\ta.mu.RLock()\n\t\tfallback := a.brokerAddr\n\t\ta.mu.RUnlock()\n\t\tif fallback != \"\" {\n\t\t\taddresses = append(addresses, fallback)\n\t\t}\n\t}\n\tif len(addresses) == 0 {\n\t\treturn nil, fmt.Errorf(\"no RocketMQ master broker found\")\n\t}\n\treturn addresses, nil\n}\n\nfunc (a *rocketMQAgent) brokerAddressForName(brokerName string) (string, error) {\n\taddresses, err := a.masterBrokerAddresses(brokerName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn addresses[0], nil\n}\n\ntype parsedMessageQueue struct {\n\tTopic      string\n\tBrokerName string\n\tQueueID    int\n}\n","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/topics.go#L426-L462","documentation":"masterBrokerAddresses collects the master (brokerId=0) address for a broker group from the nameserver route; this error is thrown when no master broker address can be resolved at all (no route data, no brokerId \"0\" entry, and no fallback address configured).","triggerScenarios":"Any operation needing a broker address — createTopic, deleteTopic, updatePartitions, getTopicConfig, alterTopicConfig, deleteConsumerGroup, alterSubscriptionGroupConfig, collectSubscriptionGroupConfigs — is called while the agent has no reachable nameserver route or the broker group registers only slaves (no id 0).","commonSituations":"Nameserver down or wrong namesrvAddr in agent config; broker cluster registered with only slave brokers (master crashed); network/partition between agent and nameserver; brokerName typo so the route lookup finds nothing and the fallback is empty.","solutions":["Verify the agent's nameserver address(es) are correct and reachable (namesrvAddr / env config) and that brokers are registered: check with `mqadmin clusterList`","Ensure a master broker (brokerId=0) for the target group is running and registered; start/restart the master if it crashed","Correct the brokerName parameter if one was passed — a wrong name yields no route and empty fallback","Configure the fallback address in agent config so operations work even when route discovery returns nothing"],"exampleFix":"// before\nagent := rocketmq.NewAgent(rocketmq.Config{}) // nameserver unset\n// after\nagent := rocketmq.NewAgent(rocketmq.Config{\n    NameServerAddrs: []string{\"10.0.0.1:9876\", \"10.0.0.2:9876\"},\n})","handlingStrategy":"fallback","validationCode":"route, err := adminClient.ExamineTopicRouteInfo(ctx, topic)\nif err != nil { return err }\nif len(route.BrokerDatas) == 0 || route.BrokerDatas[0].BrokerAddrs[\"0\"] == \"\" {\n    return fmt.Errorf(\"no master broker registered; check nameserver and broker health\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure nameserver addresses and a fallback broker address in agent config","Monitor broker master liveness (brokerId=0) with alerts","Validate brokerName spelling before invoking broker-scoped operations","Run `mqadmin clusterList` as a pre-flight health check in automation"],"tags":["rocketmq","broker","discovery","connectivity"],"backgroundTag":"no-broker-available","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"}