{"record":{"id":"b66914a265aaf06e","repo":"apache/pulsar","slug":"effective-auto-topic-creation-policy-mismatch-for","errorCode":null,"errorMessage":"Effective auto-topic creation policy mismatch for namespace '${namespaceStr}' between local cluster and remote cluster '${remoteCluster}': ${mismatches}. Please ensure auto-topic creation policies are the same before enabling replication.","messagePattern":"Effective auto-topic creation policy mismatch for namespace '(.+?)' between local cluster and remote cluster '(.+?)': (.+?)\\. Please ensure auto-topic creation policies are the same before enabling replication\\.","errorType":"http","errorClass":"RestException","httpStatus":409,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java","lineNumber":1234,"sourceCode":"                        remoteEffectiveTopicType = remoteBrokerAutoCreationType.toString();\n                        remoteEffectiveDefaultPartitions = remoteBrokerDefaultPartitions;\n                    }\n\n                    // Compare effective policies (only topicType and defaultNumPartitions)\n                    List<String> mismatches = new ArrayList<>();\n                    if (!Objects.equals(localEffectiveTopicType, remoteEffectiveTopicType)) {\n                        mismatches.add(String.format(\"topicType: local=%s, remote=%s\",\n                                localEffectiveTopicType, remoteEffectiveTopicType));\n                    }\n                    // Pulsar does not allow to set a special partition count with non-partitioned topic type, comparing\n                    // default topic count either default topic type is partitioned or non-partitioned.\n                    if (localEffectiveDefaultPartitions != remoteEffectiveDefaultPartitions) {\n                        mismatches.add(String.format(\"defaultNumPartitions: local=%d, remote=%d\",\n                                localEffectiveDefaultPartitions, remoteEffectiveDefaultPartitions));\n                    }\n\n                    if (!mismatches.isEmpty()) {\n                        throw new RestException(Status.CONFLICT,\n                                String.format(\"Effective auto-topic creation policy mismatch for namespace '%s' \"\n                                                + \"between local cluster and remote cluster '%s': %s. \"\n                                                + \"Please ensure auto-topic creation policies are the same \"\n                                                + \"before enabling replication.\",\n                                        namespaceStr, remoteCluster, String.join(\"; \", mismatches)));\n                    }\n                });\n    }\n\n    protected CompletableFuture<Void> internalSetNamespaceMessageTTLAsync(Integer messageTTL) {\n        return validateNamespacePolicyOperationAsync(namespaceName, PolicyName.TTL, PolicyOperation.WRITE)\n                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())\n                .thenAccept(__ -> {\n                    if (messageTTL != null && messageTTL < 0) {\n                        throw new RestException(Status.PRECONDITION_FAILED,\n                                \"Invalid value for message TTL, message TTL must >= 0\");\n                    }\n                }).thenCompose(__ -> updatePoliciesAsync(namespaceName, policies -> {","sourceCodeStart":1216,"sourceCodeEnd":1252,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L1216-L1252","documentation":"This 409 CONFLICT is thrown when validating replication compatibility between two clusters for a namespace: the effective auto-topic-creation policy (allowAutoTopicCreation and/or defaultNumPartitions) differs between local and remote. Geo-replication requires consistent auto-topic creation settings so topics are created identically on both sides.","triggerScenarios":"Enabling or validating replication for a namespace where one cluster has allowAutoTopicCreation=true and the other false, or the effective defaultNumPartitions (namespace override falling back to broker default) differs between the clusters.","commonSituations":"Namespace-level autoTopicCreationOverride set on one cluster but not the peer; broker.conf allowAutoTopicCreation or defaultNumberOfPartitionsForNonPartitionedTopics / defaultNumberOfBrokerPartitions differ between datacenters; a namespace was replicated before the policy changed on one cluster.","solutions":["Set the same autoTopicCreationOverride on the namespace in both clusters via admin.namespaces().setAutoTopicCreationAsync(...)","If no namespace override is intended, align broker.conf allowAutoTopicCreation and defaultNumberOfBrokerPartitions on all clusters","Read the mismatches detail in the error message (allowAutoTopicCreation / defaultNumPartitions) to see exactly which field differs and fix that field","Re-run validation after applying the policy so cached metadata is refreshed"],"exampleFix":"// before: override only set on local cluster\nadmin.namespaces().setAutoTopicCreation(\"my-tenant/my-ns\",\n    AutoTopicCreationOverride.builder().allowAutoTopicCreation(true)\n        .topicType(\"partitioned\").defaultNumPartitions(4).build());\n// after: apply the identical override on the remote cluster too\nremoteAdmin.namespaces().setAutoTopicCreation(\"my-tenant/my-ns\",\n    AutoTopicCreationOverride.builder().allowAutoTopicCreation(true)\n        .topicType(\"partitioned\").defaultNumPartitions(4).build());","handlingStrategy":"validation","validationCode":"AutoTopicCreationOverride local = admin.namespaces().getAutoTopicCreation(ns);\nAutoTopicCreationOverride remote = remoteAdmin.namespaces().getAutoTopicCreation(ns);\nif (!Objects.equals(local, remote)) throw new IllegalStateException(\"autoTopicCreationOverride differs across clusters\");","typeGuard":null,"tryCatchPattern":"try {\n    admin.namespaces().setNamespaceReplicationClusters(ns, clusters);\n} catch (PulsarAdminException.ConflictException e) {\n    // align auto-topic-creation policy, then retry\n}","preventionTips":["Apply namespace policy changes to all peer clusters in the same deployment step","Keep broker auto-topic-creation defaults consistent across datacenters","Diff namespace policies across clusters before enabling replication"],"tags":["conflict","replication","auto-topic-creation","namespace-policy"],"backgroundTag":"auto-topic-creation-mismatch","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"}