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

   Main Issue: https://github.com/apache/pulsar/issues/24977
   
   
   ### Motivation
   
   As shown in the issue, fix two problem: 1. cleanCacheAndCloseReader() 
executed twice cause concurrent error, which result in too many orphan reader 
remain in SystemTopicBasedTopicPoliciesService 2. double update in 
policyCacheInitMap cause recursive update error
   
   ### Modifications
   
   1. do cleanPolicyMap() 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 two test, to simulate if throw exception in createReader, 
initPolicyCache, readMorePolicy of prepareInitPoliciesCacheAsync. By the way, 
it seems lack of unittest in SystemTopicBasedTopicPoliciesService.
   4. "newReader()" remove some logic, it is confused when 
readCompletableFuture throw exception.
   
   
   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).
   
   Besides, this case still exist: if failed to close reader in 
cleanCacheAndCloseReader(), this closing reader maybe have chance to reconnect 
and become orphan reader. This is not this pr's work. 
   
   ### 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