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

   ### Motivation
   
   ["PIP-165 Auto release client useless 
connections"](https://github.com/apache/pulsar/issues/15516) added a solution 
that closes unused idling connections. The idle check doesn't consider topic 
watchers created by a topics pattern (regex) consumer. The impact of this is 
that connections would get frequently closed and immediately reconnected when 
topics pattern consumers are used and when the topic watcher is the only 
resource using the connection.
   
   While reviewing the code, another possible race condition was observed in 
the solution due lack of usage of volatile for ClientCnxIdleState's 
idleMarkTime field. The field gets mutated and read in different threads in 
certain cases.
   There was also a concern that a currently used connection could get released 
under a race condition. That's why this PR adds another check before the 
ClientCnxIdleState can move from IDLE to RELEASING.
   
   ### Modifications
   
   - fix the ClientCnx idleCheck method
     - check topic list watchers
   - make ClientCnxIdleState's idleMarkTime field volatile
   - add extra idleCheck in ClientCnxIdleState's doIdleDetect before the state 
can change from IDLE to RELEASING, switch to USING if the connection is getting 
used.
   - adds test coverage at different levels. There are also tests for the usage 
of Pulsar Proxy + multiple brokers.
   
   ### 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