michaeljmarshall opened a new pull request #13948:
URL: https://github.com/apache/pulsar/pull/13948


   ### Motivation
   
   Based on my reading of the `PulsarService#loadNamespaceTopics` method, it 
appears that there is a data race that could lead to the broker recreating a 
topic that was just deleted. Currently, we do the following when loading a 
namespace bundle:
   
   1. Get all topics for a namespace bundle from the metadata store.
   2. Asynchronously call `getOrCreateTopic` for each of the topics.
   
   If a topic was deleted after step 1 and before step 2, the topic will get 
recreated (assuming that auto topic creation is enabled).
   
   ### Modifications
   
   * Use `getTopicIfExists` to load a namespace bundle instead of 
`getOrCreateTopic`.
   * Only log the count of actually loaded topics.
   
   ### Verifying this change
   
   From my perspective, this is a minor change that should remove the 
possibility of a very specific race condition. I don't see an easy way to test 
this behavior. However, the `getTopics` method, which backs both 
`getTopicIfExists` and `getOrCreateTopic` is well tested, so I think it is okay 
to skip adding a test here. Let me know if you disagree.
   
   ### Does this pull request potentially affect one of the following parts:
   
   This change is not breaking in any way.
   
   ### Documentation
     
   - [x] `no-need-doc` 
     
   This internal change doesn't need docs.
   
   
   


-- 
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