{"record":{"id":"0c2ee01c4798520b","repo":"apache/pulsar","slug":"tenant-tenantname-already-references-the-resour","errorCode":null,"errorMessage":"Tenant ${tenantName} already references the resource group ${resourceGroupName}; this is unexpected","messagePattern":"Tenant (.+?) already references the resource group (.+?); this is unexpected","errorType":"exception","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java","lineNumber":210,"sourceCode":"     * @throws if the RG does not exist, or if the NS already references the RG.\n     */\n    public void registerTenant(String resourceGroupName, String tenantName) throws PulsarAdminException {\n        ResourceGroup rg = checkResourceGroupExists(resourceGroupName);\n\n        // Check that the tenant-name doesn't already have a RG association.\n        // [If it does, that should be unregistered before putting a different association.]\n        ResourceGroup oldRG = this.tenantToRGsMap.get(tenantName);\n        if (oldRG != null) {\n            String errMesg = \"Tenant \" + tenantName + \" already references a resource group: \" + oldRG.getID();\n            throw new PulsarAdminException(errMesg);\n        }\n\n        ResourceGroupOpStatus status = rg.registerUsage(tenantName, ResourceGroupRefTypes.Tenants, true,\n                                                        this.resourceUsageTransportManagerMgr);\n        if (status == ResourceGroupOpStatus.Exists) {\n            String errMesg = \"Tenant \" + tenantName + \" already references the resource group \" + resourceGroupName;\n            errMesg += \"; this is unexpected\";\n            throw new PulsarAdminException(errMesg);\n        }\n\n        // Associate this tenant name with the RG.\n        this.tenantToRGsMap.put(tenantName, rg);\n        rgTenantRegisters.labels(resourceGroupName).inc();\n\n        // Ensure schedulers are started if this is the first registration.\n        maybeStartSchedulers();\n    }\n\n    /**\n     * UnRegisters a tenant from a resource group.\n     *\n     * @param resourceGroupName\n     * @param tenantName\n     * @throws if the RG does not exist, or if the tenant does not references the RG yet.\n     */\n    public void unRegisterTenant(String resourceGroupName, String tenantName) throws PulsarAdminException {","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L192-L228","documentation":"registerTenant detected the tenant already references this same resource group, which the registration logic considers an unexpected/duplicate state; the existing association should be cleaned up before re-registering.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java:210 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unregister the tenant before registering again","Treat as idempotent success if the target RG is the intended one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}