{"record":{"id":"c7d0d88fefe7b908","repo":"apache/pulsar","slug":"namespace-fqnamespacename-already-references-a","errorCode":null,"errorMessage":"Namespace ${fqNamespaceName} already references a resource group: ${oldRG}","messagePattern":"Namespace (.+?) 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":261,"sourceCode":"        maybeStopSchedulersIfIdle();\n    }\n\n    /**\n     * Registers a namespace as a user of a resource group.\n     *\n     * @param resourceGroupName\n     * @param fqNamespaceName (i.e., in \"tenant/Namespace\" format)\n     * @throws if the RG does not exist, or if the NS already references the RG.\n     */\n    public void registerNameSpace(String resourceGroupName, NamespaceName fqNamespaceName) throws PulsarAdminException {\n        ResourceGroup rg = checkResourceGroupExists(resourceGroupName);\n\n        // Check that the NS-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.namespaceToRGsMap.get(fqNamespaceName);\n        if (oldRG != null) {\n            String errMesg = \"Namespace \" + fqNamespaceName + \" already references a resource group: \" + oldRG.getID();\n            throw new PulsarAdminException(errMesg);\n        }\n\n        ResourceGroupOpStatus status = rg.registerUsage(fqNamespaceName.toString(), ResourceGroupRefTypes.Namespaces,\n                true, this.resourceUsageTransportManagerMgr);\n        if (status == ResourceGroupOpStatus.Exists) {\n            String errMesg = String.format(\"Namespace %s already references the target resource group %s\",\n                    fqNamespaceName, resourceGroupName);\n            throw new PulsarAdminException(errMesg);\n        }\n\n        // Associate this NS-name with the RG.\n        this.namespaceToRGsMap.put(fqNamespaceName, rg);\n        rgNamespaceRegisters.labels(resourceGroupName).inc();\n\n        // Ensure schedulers are started if this is the first registration.\n        maybeStartSchedulers();\n    }\n","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L243-L279","documentation":"Namespace-level resource-group conflict in registerNameSpace: the namespace already has a resource-group association in namespaceToRGsMap and must be unregistered from it before a different RG can be assigned. Fires on namespace policy updates that set a new RG while the old binding is still active.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java:261 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unregister the namespace from its current RG first, 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-14T05:17:10.506Z"}