crossoverJie commented on issue #21653:
URL: https://github.com/apache/pulsar/issues/21653#issuecomment-1842962452

   Reproduce step:
   
   ```java
       @Test
       public void testCreateTopicAndUpdatePolicyConcurrent() throws Exception {
   
           final int topicNum = 100;
           final int partition = 10;
   
           // (1) Init topic
           admin.namespaces().createNamespace("public/retention");
           final String topicName = 
"persistent://public/retention/policy_with_broker_restart";
           for (int i = 0; i < topicNum; i++) {
               final String shadowTopicNames = topicName + "_" + i;
               admin.topics().createPartitionedTopic(shadowTopicNames, 
partition);
           }
   
           // (2) Set Policy
           for (int i = 90; i < 100; i++) {
               final String shadowTopicNames = topicName + "_" + i;
               CompletableFuture.runAsync(() -> {
                   while (true) {
                       PublishRate publishRate = new PublishRate();
                       publishRate.publishThrottlingRateInMsg = 100;
                       try {
                           
admin.topicPolicies().setPublishRate(shadowTopicNames, publishRate);
                       } catch (PulsarAdminException e) {
                       }
                   }
               });
           }
   
           for (int i = 90; i < 100; i++) {
               final String shadowTopicNames = topicName + "_" + i;
               CompletableFuture.runAsync(() -> {
                   while (true) {
                       try {
                           
admin.lookups().lookupPartitionedTopic(shadowTopicNames);
                       } catch (Exception e) {
                       }
                   }
               });
           }
   
           admin.namespaces().unload("public/retention");
           admin.namespaces().unload("public/retention");
           admin.namespaces().unload("public/retention");
           Thread.sleep(1000* 5);
   
           for (int i = 0; i < topicNum; i++) {
               final String shadowTopicNames = topicName + "_" + i;
               log.info("check topic: {}", shadowTopicNames);
               PartitionedTopicStats partitionedStats = 
admin.topics().getPartitionedStats(shadowTopicNames, true);
               Assert.assertEquals(partitionedStats.getPartitions().size(), 
partition);
           }
   
       }
   ```
   
   This issue is caused by the delay in `getPoliciesAsync` which leads to 
`checkReplication` getting an empty array when it tries to get 
`configuredClusters`.
   
   We can manually add a delay here to simulate the issue for this unit test to 
reproduce the problem.
   
![image](https://github.com/apache/pulsar/assets/15684156/72d679de-cd3d-4614-b75a-86dbeeeb1af7)
   


-- 
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-unsubscr...@pulsar.apache.org

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

Reply via email to