{"record":{"id":"a430daab7bc553a1","repo":"apache/pulsar","slug":"resource-group-name-still-has-tenantrefcount","errorCode":null,"errorMessage":"Resource group ${name} still has ${tenantRefCount} tenant refs and ${nsRefCount} namespace refs on it","messagePattern":"Resource group (.+?) still has (.+?) tenant refs and (.+?) namespace refs on it","errorType":"exception","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java","lineNumber":173,"sourceCode":"    }\n\n    /**\n     * Delete RG.\n     *\n     * @throws if RG with that name does not exist, or if the RG exists but is still in use.\n     */\n    public void resourceGroupDelete(String name) throws PulsarAdminException {\n        ResourceGroup rg = this.getResourceGroupInternal(name);\n        if (rg == null) {\n            throw new PulsarAdminException(\"Resource group does not exist: \" + name);\n        }\n\n        long tenantRefCount = rg.getResourceGroupNumOfTenantRefs();\n        long nsRefCount = rg.getResourceGroupNumOfNSRefs();\n        if ((tenantRefCount + nsRefCount) > 0) {\n            String errMesg = \"Resource group \" + name + \" still has \" + tenantRefCount + \" tenant refs\";\n            errMesg += \" and \" + nsRefCount + \" namespace refs on it\";\n            throw new PulsarAdminException(errMesg);\n        }\n\n        rg.resourceGroupPublishLimiter = null;\n        resourceGroupsMap.remove(name);\n    }\n\n    /**\n     * Get the current number of RGs. For testing.\n     */\n    protected long getNumResourceGroups() {\n        return resourceGroupsMap.mappingCount();\n    }\n\n    /**\n     * Registers a tenant as a user of a resource group.\n     *\n     * @param resourceGroupName\n     * @param tenantName","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L155-L191","documentation":"resourceGroupDelete refuses to delete a resource group that is still referenced by tenants or namespaces; the refcounts must be zero (unregister all tenants/namespaces from the RG) before deletion can succeed.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java:173 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unregister all tenants and namespaces from the RG (set another RG or none), then delete","List referencing tenants/namespaces from the error counts in the message"],"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-14T05:17:10.506Z"}