mattisonchao opened a new pull request #14503:
URL: https://github.com/apache/pulsar/pull/14503


   ### Motivation
   
   The current exception handler does not clean all states, which will cause 
some wrong behaviour. 
   
   **E.g:**
   
   case 1:
   
   
https://github.com/apache/pulsar/blob/e20f34bd2a6b4bd7ce72390a593931a855f8e250/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java#L249-L264
   
   when line 259 closes the reader by exception, it does not remove 
``policyCacheInitMap ``, so when next invoke this method they will do nothing 
because ``policyCacheInitMap.putIfAbsent(namespace, false)`` is not null.
   
   then line 201 will always throw.
   
   
https://github.com/apache/pulsar/blob/e20f34bd2a6b4bd7ce72390a593931a855f8e250/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java#L193-L205
   
   case 2:
   
   When line 384 gets "AlreadyClosedException", it doesn't delete 
"policyCacheInitMap", but the current namespace value in "policyCacheInitMap" 
is true. Therefore, the next time ``prepareInitPoliciesCache `` is called, a 
new reader is never created. then we will always get a null value.
   
   
https://github.com/apache/pulsar/blob/e20f34bd2a6b4bd7ce72390a593931a855f8e250/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java#L376-L393
   
   ### Modifications
   
   - Clean state when the reader gets an error.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   ### Documentation
   
   - [x] `no-need-doc` 
   
   


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