BewareMyPower commented on a change in pull request #11683:
URL: https://github.com/apache/pulsar/pull/11683#discussion_r690975274



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -3636,6 +3636,15 @@ private PersistentReplicator 
getReplicatorReference(String replName, PersistentT
                         p -> new PartitionedTopicMetadata(numPartitions));
                 updatePartition.complete(null);
             } catch (Exception e) {
+                getPartitionedTopicMetadataAsync(topicName, false, 
false).thenAccept(metadata -> {
+                    int oldPartition = metadata.partitions;
+                    for(int i = oldPartition; i < numPartitions; i++){
+                        
namespaceResources().getPartitionedTopicResources().deleteAsync(ZkAdminPaths.managedLedgerPath(topicName.getPartition(i)));

Review comment:
       Should we add the error logs or retry when `deleteAsync` failed?

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -3636,6 +3637,20 @@ private PersistentReplicator 
getReplicatorReference(String replName, PersistentT
                         p -> new PartitionedTopicMetadata(numPartitions));
                 updatePartition.complete(null);
             } catch (Exception e) {
+                getPartitionedTopicMetadataAsync(topicName, false, 
false).thenAccept(metadata -> {
+                    int oldPartition = metadata.partitions;
+                    for (int i = oldPartition; i < numPartitions; i++) {
+                        String managedLedgerPath = 
ZkAdminPaths.managedLedgerPath(topicName.getPartition(i));
+                        try {
+                            
namespaceResources().getPartitionedTopicResources().deleteAsync(managedLedgerPath);
+                        } catch (Exception cleanZnodeException) {
+                            log.error("Failed to clean managedLedger znode 
{}", managedLedgerPath, cleanZnodeException);
+                        }

Review comment:
       `deleteAsync` is an asynchronous method that doesn't throw exception, we 
shouldn't need to catch the exception whose type we don't know. Instead, we 
should use `whenComplete` or `exceptionally` to process the exception of the 
future returned by `deleteAsync`.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to