{"record":{"id":"a0b8d759a1bf5495","repo":"apache/pulsar","slug":"restexception-e","errorCode":null,"errorMessage":"RestException(e)","messagePattern":"RestException\\(e\\)","errorType":"exception","errorClass":"RestException","httpStatus":500,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceGroupsBase.java","lineNumber":92,"sourceCode":"                resourceGroup.setDispatchRateInMsgs(rgConfig.getDispatchRateInMsgs());\n            }\n            if (rgConfig.getDispatchRateInBytes() != null) {\n                resourceGroup.setDispatchRateInBytes(rgConfig.getDispatchRateInBytes());\n            }\n\n            // write back the new ResourceGroup config.\n            resourceGroupResources().updateResourceGroup(rgName, r -> resourceGroup);\n            log.info()\n                    .attr(\"resourceGroup\", rgName)\n                    .log(\"Successfully updated the ResourceGroup\");\n        } catch (RestException pfe) {\n            throw pfe;\n        } catch (Exception e) {\n            log.error()\n                    .attr(\"resourceGroup\", rgName)\n                    .exception(e)\n                    .log(\"Failed to update configuration for ResourceGroup\");\n            throw new RestException(e);\n        }\n    }\n\n    protected void internalCreateResourceGroup(String rgName, ResourceGroup rgConfig) {\n        rgConfig.setPublishRateInMsgs(rgConfig.getPublishRateInMsgs() == null\n                ? -1 : rgConfig.getPublishRateInMsgs());\n        rgConfig.setPublishRateInBytes(rgConfig.getPublishRateInBytes() == null\n                ? -1 : rgConfig.getPublishRateInBytes());\n        rgConfig.setDispatchRateInMsgs(rgConfig.getDispatchRateInMsgs() == null\n                ? -1 : rgConfig.getDispatchRateInMsgs());\n        rgConfig.setDispatchRateInBytes(rgConfig.getDispatchRateInBytes() == null\n                ? -1 : rgConfig.getDispatchRateInBytes());\n        try {\n            resourceGroupResources().createResourceGroup(rgName, rgConfig);\n            log.info().attr(\"resourceGroup\", rgName).log(\"Created ResourceGroup\");\n        } catch (MetadataStoreException.AlreadyExistsException e) {\n            log.warn()\n                    .attr(\"resourceGroup\", rgName)","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceGroupsBase.java#L74-L110","documentation":"A generic RestException wrapping any unexpected Exception thrown while updating a resource group's configuration (internalUpdateResourceGroup, invoked from the create-or-update path). Not-found and validation errors are rethrown earlier; anything else (usually a metadata store write failure) is logged as 'Failed to update configuration for ResourceGroup' and rethrown as a 500 RestException. The wrapped cause in the broker log holds the real problem.","triggerScenarios":"PUT /admin/v3/resourcegroups/{rgName} (or internalCreateOrUpdateResourceGroup choosing update) when the metadata store put/compare-and-set fails, the store session expires mid-write, or an unexpected exception occurs during validation of rate limits.","commonSituations":"Config-store write timeouts during cluster churn; ZooKeeper session loss; concurrent writers causing CAS conflicts surfaced as generic exceptions; invalid quota values that slipped past pre-validation.","solutions":["Check the broker log 'Failed to update configuration for ResourceGroup' for the wrapped cause.","Verify metadata store health and retry after the store recovers.","Validate publish/dispatch rate fields (non-negative where required) before issuing the update.","Retry the update; if conflicts persist, serialize writes to the same resource group."],"exampleFix":"// before\nadmin.resourcegroups().updateResourceGroup(rgName, rg); // opaque 500\n// after\ntry {\n    admin.resourcegroups().updateResourceGroup(rgName, rg);\n} catch (PulsarAdminException e) {\n    log.error(\"Update of resource group {} failed\", rgName, e); // see broker log cause\n    throw e;\n}","handlingStrategy":"retry","validationCode":"// validate before calling\nif (rg.getPublishRateInMsgs() != null && rg.getPublishRateInMsgs() < -1)\n    throw new IllegalArgumentException(\"invalid publishRateInMsgs\");","typeGuard":"null","tryCatchPattern":"try {\n    admin.resourcegroups().updateResourceGroup(rgName, rg);\n} catch (PulsarAdminException e) {\n    if (e.getStatusCode() >= 500) retryWithBackoff();\n    else throw e;\n}","preventionTips":["Validate rate/quota fields client-side before update.","Serialize updates to the same resource group to avoid write conflicts.","Retry transient 5xx responses with exponential backoff."],"tags":["rest-api","metadata-store","resourcegroups","update-failed"],"backgroundTag":"metadata-store-write-failed","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"}