You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/08/24 09:11:05 UTC

[GitHub] [pulsar] HQebupt commented on a diff in pull request #17251: [fix][broker]fail to update partition meta of topic due to ConflictException: subscription already exists for topic

HQebupt commented on code in PR #17251:
URL: https://github.com/apache/pulsar/pull/17251#discussion_r953549932


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -4355,38 +4356,50 @@ private PersistentReplicator getReplicatorReference(String replName, PersistentT
         }
     }
 
+    private CompletableFuture<Void> updatePartitionedTopicMetadataAsync(int numPartitions) {
+        CompletableFuture<Void> future = namespaceResources().getPartitionedTopicResources()
+                .updatePartitionedTopicAsync(topicName, p -> new PartitionedTopicMetadata(numPartitions));
+        future.exceptionally(ex -> {
+            // If the update operation fails, clean up the partitions that were created
+            getPartitionedTopicMetadataAsync(topicName, false, false).thenAccept(metadata -> {
+                int oldPartition = metadata.partitions;
+                for (int i = oldPartition; i < numPartitions; i++) {
+                    topicResources().deletePersistentTopicAsync(topicName.getPartition(i)).exceptionally(ex1 -> {
+                        log.warn("[{}] Failed to clean up managedLedger {}", clientAppId(), topicName,
+                                ex1.getCause());
+                        return null;
+                    });
+                }

Review Comment:
   No, it does not. The method only shrink the new partitions when `updatePartitionedTopicAsync` occur exception.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org