TakaHiR07 opened a new pull request, #24978:
URL: https://github.com/apache/pulsar/pull/24978

   
   
   Fixes https://github.com/apache/pulsar/issues/24977
   
   
   ### Motivation
   
   As shown in the issue, fix two problem: 1. cleanCacheAndCloseReader() 
executed twice cause concurrent error, 2. double update in policyCacheInitMap 
cause recursive update error
   
   ### Modifications
   
   1. no need to do cleanCacheAndCloseReader() when throw exception, since the 
exception would be catch in outside code. By the way, in previous 
pulsar-version 2.9.x, cleanCacheAndCloseReader is also executed only once
   2. avoid double update in policyCacheInitMap. use putIfAbsent instead of 
computeIfAbsent. It is not appropriate to add so many operation into compute(). 
   3. add a test to simulate if reader fail in prepareInitPoliciesCacheAsync. 
By the way, it seems lack of unittest in SystemTopicBasedTopicPoliciesService.
   
   
   There is one point should be consider in this pr
   1. When use putIfAbsent, if too many getTopicPolicy() trigger 
prepareInitPoliciesCacheAsync, it would generate many empty completableFuture. 
Further more, we can use double check in the code to avoid this object gc.(the 
code would be longer).
   
   ### Verifying this change
   
   - [] Make sure that the change passes the CI checks.
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   
   


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