{"record":{"id":"7c4d97fe69ab2c2f","repo":"apache/pulsar","slug":"exist-unexpected-topic-partition-partition-index-g","errorCode":null,"errorMessage":"Exist unexpected topic partition(partition index grater than current metadata maximum index %s) %s ","messagePattern":"Exist unexpected topic partition\\(partition index grater than current metadata maximum index (.+?)\\) (.+?) ","errorType":"http","errorClass":"RestException","httpStatus":409,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java","lineNumber":426,"sourceCode":"                            .thenAccept(topics -> {\n                                final List<TopicName> existingPartitions = topics.stream()\n                                        .map(TopicName::get)\n                                        .filter(candidateTopicName -> candidateTopicName.getPartitionedTopicName()\n                                                .equals(topicName.getPartitionedTopicName()))\n                                        .collect(Collectors.toList());\n                                    // Check whether exist unexpected partition\n                                    Optional<Integer> maximumPartitionIndex = existingPartitions.stream()\n                                            .map(TopicName::getPartitionIndex)\n                                            .max(Integer::compareTo);\n                                    if (maximumPartitionIndex.isPresent()\n                                            && maximumPartitionIndex.get() >= currentMetadataPartitions) {\n                                        List<String> unexpectedPartitions = existingPartitions.stream()\n                                                .filter(candidateTopicName ->\n                                                        candidateTopicName\n                                                                .getPartitionIndex() > currentMetadataPartitions)\n                                                .map(TopicName::toString)\n                                                .collect(Collectors.toList());\n                                        throw new RestException(Status.CONFLICT,\n                                                String.format(\n                                                        \"Exist unexpected topic partition(partition index grater than\"\n                                                                + \" current metadata maximum index %s) %s \",\n                                                        currentMetadataPartitions,\n                                                        StringUtils.join(unexpectedPartitions, \",\")));\n                                    }\n                            });\n                } else {\n                    checkFuture = CompletableFuture.completedFuture(null);\n                }\n                return checkFuture.thenCompose(topics -> {\n                    final CompletableFuture<Void> updateMetadataFuture = (expectPartitions == currentMetadataPartitions)\n                            // current metadata partitions is equals to expect partitions\n                            ? CompletableFuture.completedFuture(null)\n                            // update current cluster topic metadata\n                            : namespaceResources().getPartitionedTopicResources()\n                            .updatePartitionedTopicAsync(topicName, m ->\n                                    new PartitionedTopicMetadata(expectPartitions, m.properties));","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L408-L444","documentation":"During partition expansion the broker found an existing topic partition whose index is beyond the current metadata's maximum index — an inconsistent leftover partition, usually from a previously failed update.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:426 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the orphaned high-index partitions and retry the update","Use the force flag if available to proceed despite the inconsistency"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}