{"record":{"id":"8db121145165c2cd","repo":"apache/pulsar","slug":"tenant-tenantname-already-references-a-resource","errorCode":null,"errorMessage":"Tenant ${tenantName} already references a resource group: ${oldRG}","messagePattern":"Tenant (.+?) already references a resource group: (.+?)","errorType":"exception","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java","lineNumber":202,"sourceCode":"        return resourceGroupsMap.mappingCount();\n    }\n\n    /**\n     * Registers a tenant as a user of a resource group.\n     *\n     * @param resourceGroupName\n     * @param tenantName\n     * @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","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L184-L220","documentation":"Resource-group registration conflict in registerTenant: the tenant is already mapped to another (or the same) resource group in tenantToRGsMap, and Pulsar requires the old association to be unregistered before a new one can be set. Fires when create-tenant or update-tenant reassigns a tenant that still holds an active RG reference.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java:202 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unregister the tenant from the old resource group, then register the new 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"}