dao-jun opened a new pull request, #24658:
URL: https://github.com/apache/pulsar/pull/24658

   ### Motivation
   
   In our cluster, we encountered an exception on a `change_events` partition:
   <img width="2052" height="1274" alt="image" 
src="https://github.com/user-attachments/assets/eefea926-1ee3-4bcb-9385-9712d36fb3e4";
 />
   Thousands of `get last message id failed` was thrown due to `No such ledger` 
exception.
   
   In the `SystemTopicBasedTopicPoliciesService`, it will create thousands of 
`Reader` instances.
   
   For some reason, all the `Reader`s didn't closed successfully(maybe we were 
unload the ns at the time), after the `change_events` partition transferred to 
a new broker, all the `Reader`s was reconnected to the new broker, and never be 
closed.
   <img width="1837" height="1277" alt="image" 
src="https://github.com/user-attachments/assets/021ad174-b031-4362-965b-51ea73710ff9";
 />
   
   There was more than 20k consumers of the partition of `change_events`:
   <img width="1795" height="254" alt="image" 
src="https://github.com/user-attachments/assets/421f0a7e-807e-42a8-98b1-b262bd618362";
 />
     
   
   ### Modifications
   
   Don't clean the `readerCache` and close the `Reader` unless:
   1. The consumer was already closed
   2. All ns bundles were removed from the broker
   3. The reader creation was failed
   4. TopicPoliciesService was closed
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe 
tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads 
(10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### 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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to