hangc0276 opened a new pull request #11136:
URL: https://github.com/apache/pulsar/pull/11136


   ### Motivation
   When set topic level retention policy for a topic and restart the broker, 
the topic level retention policy doesn't work.
   The reason is when replay the __change_events topic message on 
`initPolicesCache` stage, it create a reader and read message from earliest and 
notify the message to update policy for each topic. On update topic policy, it 
will call getTopicPolicies method.
   ```Java
   public TopicPolicies getTopicPolicies(TopicName topicName) throws 
TopicPoliciesCacheNotInitException {
           if (policyCacheInitMap.containsKey(topicName.getNamespaceObject())
                   && !policyCacheInitMap.get(topicName.getNamespaceObject())) {
               throw new TopicPoliciesCacheNotInitException();
           }
           return policiesCache.get(topicName);
       }
   ```
   This method will check `policyCacheInitMap` whether init or not for specific 
namespace. 
   However, before replay all message completely, the `policyCacheInitMap` keep 
in not init stage. 
   Thus the `getTopicPolicies` will throw `TopicPoliciesCacheNotInitException` 
and the topic policy message will replay failed. 
   
   ### Modification
   1. replay all policy messages after `policyCacheInitMap` initiated.
   2. add retention policy check test for broker restart check.


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