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 2021/02/11 14:10:48 UTC

[GitHub] [pulsar] lhotari opened a new issue #9564: [Broker] Topic auto-creation fails due to a race condition

lhotari opened a new issue #9564:
URL: https://github.com/apache/pulsar/issues/9564


   **Describe the bug**
   Topic auto-creation fails due to a race condition. This seems to happen to be one of the issues causing flakiness in PulsarFunctionLocalRunTest, reported as #8720 .
   
   **To Reproduce**
   ```
       @Test
       public void shouldNotPreventCreatingTopicWhenNonexistingTopicIsCached() throws Exception {
           // run multiple iterations to increase the chance of reproducing a race condition in the topic cache
           for (int i=0; i < 100; i++) {
               final String topicName = "persistent://prop/ns-abc/topic-caching-test-topic" + i;
               CountDownLatch latch = new CountDownLatch(1);
               Thread getStatsThread = new Thread(() -> {
                   try {
                       latch.countDown();
                       // create race condition with a short delay
                       // the bug might not reproduce in all environments, this works at least on i7-10750H CPU
                       Thread.sleep(1);
                       admin.topics().getStats(topicName);
                       fail("The topic should not exist yet.");
                   } catch (PulsarAdminException.NotFoundException e) {
                       // expected exception
                   } catch (PulsarAdminException | InterruptedException e) {
                       e.printStackTrace();
                   }
               });
               getStatsThread.start();
               latch.await();
               @Cleanup
               Producer<byte[]> producer = pulsarClient.newProducer().topic(topicName).create();
               assertNotNull(producer);
               getStatsThread.join();
           }
       }
   ```
   
   **Expected behavior**
   A topic should get created when topic auto-creation is enabled.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on issue #9564: [Broker] Topic auto-creation fails due to a race condition

Posted by GitBox <gi...@apache.org>.
lhotari commented on issue #9564:
URL: https://github.com/apache/pulsar/issues/9564#issuecomment-777486114


   I'll submit a PR for this soon.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] merlimat closed issue #9564: [Broker] Topic auto-creation fails due to a race condition

Posted by GitBox <gi...@apache.org>.
merlimat closed issue #9564:
URL: https://github.com/apache/pulsar/issues/9564


   


----------------------------------------------------------------
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:
users@infra.apache.org