apache/pulsar · error · RestException
Desired partitions can't be greater than the maximum…
Error message
Desired partitions %s can't be greater than the maximum partitions per topic %s.
What it means
internalUpdatePartitionedTopicAsync pre-check failure (422): the requested partition count exceeds the cluster's maximum allowed partitions per topic, so the update is rejected to prevent creating more partitions than the broker configuration permits.
Solutions
- Request a count within maxPartitionsPerTopic
- Ask the admin to raise maxPartitionsPerTopic if a larger topic is genuinely needed
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:394 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/221bfa914c0f108d.
Report an issue: GitHub.
Appendix: source
Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:394
boolean updateLocal,
boolean force) {
PulsarService pulsarService = pulsar();
return pulsarService.getBrokerService().fetchPartitionedTopicMetadataAsync(topicName)
.thenCompose(partitionedTopicMetadata -> {
int currentMetadataPartitions = partitionedTopicMetadata.partitions;
if (currentMetadataPartitions <= 0) {
throw new RestException(Status.CONFLICT /* Unprocessable entity*/,
String.format("Topic %s is not the partitioned topic.", topicName));
}
if (expectPartitions < currentMetadataPartitions) {
throw new RestException(422 /* Unprocessable entity*/,
String.format("Desired partitions %s can't be less than the current partitions %s.",
expectPartitions, currentMetadataPartitions));
}
int brokerMaximumPartitionsPerTopic = pulsarService.getConfiguration()
.getMaxNumPartitionsPerPartitionedTopic();
if (brokerMaximumPartitionsPerTopic > 0 && expectPartitions > brokerMaximumPartitionsPerTopic) {
throw new RestException(422 /* Unprocessable entity*/,
String.format("Desired partitions %s can't be greater than the maximum partitions per"
+ " topic %s.",
expectPartitions, brokerMaximumPartitionsPerTopic));
}
final PulsarAdmin admin;
try {
admin = pulsarService.getAdminClient();
} catch (PulsarServerException ex) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, Throwables.getRootCause(ex));
}
final CompletableFuture<Void> checkFuture;
if (!force) {
checkFuture = admin.topics().getListAsync(topicName.getNamespace(), topicName.getDomain())
.thenAccept(topics -> {
final List<TopicName> existingPartitions = topics.stream()
.map(TopicName::get)
.filter(candidateTopicName -> candidateTopicName.getPartitionedTopicName()
.equals(topicName.getPartitionedTopicName()))View on GitHub (pinned to 820761864e)