apache/pulsar · error · RestException
This topic already exists
Error message
This topic already exists
What it means
internalCreateNonPartitionedTopicAsync detected that the topic being created already exists on the broker, so creation is refused with 409 Conflict rather than overwriting the existing topic's metadata.
Source
Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:351
resumeAsyncResponseExceptionally(asyncResponse, realCause);
return null;
});
}
protected CompletableFuture<Void> internalCreateNonPartitionedTopicAsync(boolean authoritative,
Map<String, String> properties) {
return validateNonPartitionTopicNameAsync(topicName.getLocalName())
.thenCompose(__ -> validateGlobalNamespaceOwnershipAsync(namespaceName))
.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative))
.thenCompose(__ -> validateNamespaceOperationAsync(topicName.getNamespaceObject(),
NamespaceOperation.CREATE_TOPIC))
.thenCompose(__ -> getPartitionedTopicMetadataAsync(topicName, false, false))
.thenAccept(partitionMetadata -> {
if (partitionMetadata.partitions > 0) {
log.warn()
.attr("exists", topicName)
.log("Partitioned topic with the same name already exists");
throw new RestException(Status.CONFLICT, "This topic already exists");
}
})
.thenCompose(__ -> pulsar().getBrokerService().getTopicIfExists(topicName.toString()))
.thenCompose(existedTopic -> {
if (existedTopic.isPresent()) {
log.warn().attr("topic", topicName).log("Topic already exists");
throw new RestException(Status.CONFLICT, "This topic already exists");
}
return pulsar().getBrokerService().getTopic(topicName.toString(), true, properties);
})
.thenAccept(__ -> log.info()
.attr("topic", topicName)
.log("Successfully created non-partitioned topic"));
}
/**
* It updates number of partitions of an existing partitioned topic. It requires partitioned-topic to
* already exist and number of new partitions must be greater than existing number of partitions. DecrementingView on GitHub (pinned to 820761864e)
Solutions
- Use the existing topic instead of creating it
- Pass the appropriate create-or-continue semantics if supported by the client
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:351 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/42a978ea10976b0e.
Report an issue: GitHub.