{"record":{"id":"f1769cf6d7db2d89","repo":"apache/pulsar","slug":"exceed-the-maximum-number-of-namespace-in-tenant","errorCode":null,"errorMessage":"Exceed the maximum number of namespace in tenant :${tenant}","messagePattern":"Exceed the maximum number of namespace in tenant :(.+?)","errorType":"http","errorClass":"RestException","httpStatus":412,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java","lineNumber":165,"sourceCode":"                    if (!existed) {\n                        throw new RestException(Status.NOT_FOUND, \"Tenant not found\");\n                    }\n                    return tenantResources().getListOfNamespacesAsync(tenant);\n                });\n    }\n\n    protected CompletableFuture<Void> internalCreateNamespace(Policies policies) {\n        return validateTenantOperationAsync(namespaceName.getTenant(), TenantOperation.CREATE_NAMESPACE)\n                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())\n                .thenCompose(__ -> validatePoliciesAsync(namespaceName, policies))\n                .thenCompose(__ -> {\n                    int maxNamespacesPerTenant = pulsar().getConfiguration().getMaxNamespacesPerTenant();\n                    // no distributed locks are added here.In a concurrent scenario, the threshold will be exceeded.\n                    if (maxNamespacesPerTenant > 0) {\n                        return tenantResources().getListOfNamespacesAsync(namespaceName.getTenant())\n                                .thenAccept(namespaces -> {\n                                    if (namespaces != null && namespaces.size() > maxNamespacesPerTenant) {\n                                        throw new RestException(Status.PRECONDITION_FAILED,\n                                                \"Exceed the maximum number of namespace in tenant :\"\n                                                        + namespaceName.getTenant());\n                                    }\n                                });\n                    }\n                    return CompletableFuture.completedFuture(null);\n                })\n                .thenCompose(__ -> namespaceResources().createPoliciesAsync(namespaceName, policies))\n                .thenAccept(__ -> log.info()\n                        .attr(\"namespace\", namespaceName)\n                        .log(\"Created namespace\"));\n    }\n\n    protected CompletableFuture<List<String>> internalGetListOfTopics(AsyncResponse response, Policies policies,\n                                                                      CommandGetTopicsOfNamespace.Mode mode) {\n        // Use maxTopicListInFlightLimiter to limit inflight get topic listing responses\n        // to avoid OOME caused by a lot of clients using HTTP service lookups to list topics\n        AsyncDualMemoryLimiterImpl maxTopicListInFlightLimiter =","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L147-L183","documentation":"A 412 PRECONDITION_FAILED thrown when creating a namespace would exceed the broker's maxNamespacesPerTenant limit. If the limit is > 0, the broker counts existing namespaces in the tenant and rejects creation when the count already exceeds it. The comment in the source notes there is no distributed lock, so under concurrency the threshold can be exceeded.","triggerScenarios":"pulsar-admin namespaces create or Namespaces.createNamespace when the tenant already has more namespaces than maxNamespacesPerTenant (broker.conf, 0 = unlimited); concurrent creations racing past the check.","commonSituations":"Environments where the limit was lowered after many namespaces already exist; CI/test suites mass-creating namespaces; concurrent provisioning scripts exceeding the soft (unlocked) limit.","solutions":["Raise or disable the limit: set maxNamespacesPerTenant=0 (unlimited) or a higher value in broker.conf and restart/roll brokers.","Delete unused namespaces in the tenant to get under the limit.","Use the tenant's existing namespaces (reuse rather than create) — list via GET /admin/v3/namespaces/{tenant}."],"exampleFix":"# before: broker.conf\nmaxNamespacesPerTenant=10\n# after\nmaxNamespacesPerTenant=0  # or a value above current usage","handlingStrategy":"validation","validationCode":"int existing = admin.namespaces().getNamespaces(tenant).size();\nint max = brokerConf.getMaxNamespacesPerTenant(); // >0 means enforced\nif (max > 0 && existing >= max) {\n  throw new IllegalStateException(\"tenant \" + tenant + \" is at namespace limit \" + max);\n}","typeGuard":null,"tryCatchPattern":"try { admin.namespaces().createNamespace(ns); }\ncatch (PulsarAdminException e) {\n  if (e.getStatusCode() == 412) { /* raise limit or reuse existing ns */ }\n  else throw e;\n}","preventionTips":["Set maxNamespacesPerTenant=0 if unlimited is intended","When lowering the limit, first verify current namespace counts fit","Avoid concurrent mass namespace creation against one tenant","Reuse namespaces instead of creating new ones in CI loops"],"tags":["quota","namespace","rest-api","admin"],"backgroundTag":"quota-exceeded","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"}