sijie commented on a change in pull request #5572: Fix create consumer on 
partitioned topic while disable topic auto creation.
URL: https://github.com/apache/pulsar/pull/5572#discussion_r348629570
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
 ##########
 @@ -233,6 +233,23 @@ public void validatePoliciesReadOnlyAccess() {
         return namespaces;
     }
 
+    protected void tryCreatePartitions(int numPartitions) {
+        if (!topicName.isPersistent()) {
+            return;
+        }
+        for (int i = 0; i < numPartitions; i++) {
+            try {
+                
zkCreateOptimistic(ZkAdminPaths.managedLedgerPath(topicName.getPartition(i)), 
new byte[0]);
+            } catch (KeeperException.NodeExistsException e) {
+                log.warn("[{}] Topic partition is already existing, doing 
nothing {}", clientAppId(), topicName.getPartition(i));
+            } catch (KeeperException.BadVersionException e) {
+                log.warn("[{}] Fail to create topic partition {}: concurrent 
modification", clientAppId(), topicName.getPartition(i));
 
 Review comment:
   do we need to handle bad version exception and retry the creation?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to