apache/pulsar · error · RestException

Topic %s does not exist

Error message

Topic %s does not exist

What it means

HTTP 404 raised by internalCreateMissedPartitions when the partitioned topic metadata lookup reports no partitioned topic (metadata null or partitions <= 0). The create-missed-partitions admin endpoint only recreates missing individual partitions for an existing partitioned topic; if the partitioned parent topic does not exist in metadata, there is nothing to repair and the broker returns NOT_FOUND.

Source

Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:581

        });
    }

    protected void internalCreateMissedPartitions(AsyncResponse asyncResponse) {
        getPartitionedTopicMetadataAsync(topicName, false, false).thenAccept(metadata -> {
            if (metadata != null && metadata.partitions > 0) {
                validateNamespaceOperationAsync(topicName.getNamespaceObject(),
                        NamespaceOperation.CREATE_TOPIC)
                .thenCompose(__ -> tryCreatePartitionsAsync(metadata.partitions)).thenAccept(v -> {
                    asyncResponse.resume(Response.noContent().build());
                }).exceptionally(e -> {
                    log.error()
                            .attr("topic", topicName)
                            .log("Failed to create partitions for topic");
                    resumeAsyncResponseExceptionally(asyncResponse, e);
                    return null;
                });
            } else {
                throw new RestException(Status.NOT_FOUND, String.format("Topic %s does not exist", topicName));
            }
        }).exceptionally(ex -> {
            // If the exception is not redirect exception we need to log it.
            if (!isRedirectException(ex)) {
                log.error()
                        .attr("topic", topicName)
                        .log("Failed to create partitions for topic");
            }
            resumeAsyncResponseExceptionally(asyncResponse, ex);
            return null;
        });
    }

    protected CompletableFuture<Void> internalSetDelayedDeliveryPolicies(DelayedDeliveryPolicies deliveryPolicies,
                                                                         boolean isGlobal) {
        return pulsar().getTopicPoliciesService()
                .updateTopicPoliciesAsync(topicName, isGlobal, deliveryPolicies == null, policies -> {
                    policies.setDelayedDeliveryEnabled(deliveryPolicies == null ? null : deliveryPolicies.isActive());

View on GitHub (pinned to 820761864e)

Solutions

  1. First create the partitioned topic: `pulsar-admin topics create-partitioned-topic <topic> -p <n>`, then retry create-missed-partitions.
  2. Verify the exact topic name/tenant/namespace with `pulsar-admin topics list-partitioned-topics <namespace>`.
  3. If metadata should exist, inspect ZooKeeper/metadata store path for the partitioned topic and check broker logs for metadata lookup failures.
  4. Use the non-partitioned topic name without the `-partition-` suffix — the endpoint expects the partitioned parent name.

Example fix

// before
pulsar-admin topics create-missed-partitions persistent://my-tenant/my-ns/my-topic
// after (create the partitioned topic first)
pulsar-admin topics create-partitioned-topic persistent://my-tenant/my-ns/my-topic -p 4
pulsar-admin topics create-missed-partitions persistent://my-tenant/my-ns/my-topic
Defensive patterns

Strategy: validation

Validate before calling

PartitionedTopicMetadata meta;
try {
    meta = admin.topics().getPartitionedTopicMetadata(topic);
} catch (PulsarAdminException.NotFoundException e) {
    admin.topics().createPartitionedTopic(topic, 4); // create first
}
admin.topics().createMissedPartitions(topic);

Try / catch

try {
    admin.topics().createMissedPartitions(topic);
} catch (PulsarAdminException.NotFoundException e) {
    // partitioned topic absent: create it first or skip
}

Prevention

When it happens

Trigger: POST /admin/v2/persistent/{ns}/{topic}/createMissedPartitions (or `pulsar-admin topics create-missed-partitions`) on a topic that was never created as a partitioned topic, or whose partitioned metadata was deleted.

Common situations: Typo in the topic name (partitioned topic actually named differently); calling create-missed-partitions before ever running create-partitioned-topic; partitioned metadata deleted after partitions were removed; pointing at the wrong tenant/namespace.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/36436231a72633ef. Report an issue: GitHub.