{"record":{"id":"9efe408bc0b4e9ba","repo":"apache/pulsar","slug":"namespace-s-already-references-the-target-resourc","errorCode":null,"errorMessage":"Namespace %s already references the target resource group %s","messagePattern":"Namespace (.+?) already references the target resource group (.+?)","errorType":"exception","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java","lineNumber":269,"sourceCode":"     * @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\n    /**\n     * UnRegisters a namespace from 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 does not references the RG yet.\n     */\n    public void unRegisterNameSpace(String resourceGroupName, NamespaceName fqNamespaceName)","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L251-L287","documentation":"Redundant re-registration detected in registerNameSpace: the namespace found in namespaceToRGsMap is already bound to exactly the target resource group, so the registration request is rejected as a no-op duplicate rather than silently succeeding; the caller should skip or unregister first.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java:269 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as already-registered; no action needed","Unregister first if a fresh registration is required"],"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"}