oneby-wang opened a new pull request, #25899:
URL: https://github.com/apache/pulsar/pull/25899

   ### Motivation
   
   apache/pulsar#25892 fixed a flaky 
`SameAuthParamsLookupAutoClusterFailoverTest` by removing an extra manual 
`failover.initialize(client)` call from the test.
   
   The root cause of that flakiness was duplicate initialization. 
`PulsarClientBuilder.build()` already initializes the configured 
`ServiceUrlProvider` through `PulsarClientImpl`, so calling 
`initialize(client)` again starts duplicate background checks for the same 
provider instance.
   
   This is especially problematic for 
`SameAuthParamsLookupAutoClusterFailover`, because each `initialize` call 
creates a new `broker-service-url-check` `EventLoopGroup`. Multiple checker 
threads can then mutate the same failover state and produce subtle race 
conditions that are difficult to diagnose. `AutoClusterFailover` and 
`ControlledClusterFailover` have the same lifecycle risk: duplicate 
initialization can register duplicate scheduled tasks, and 
`ControlledClusterFailover` can also recreate its HTTP client without closing 
the previous one.
   
   ### Modifications
   
   - Make AutoClusterFailover, ControlledClusterFailover, and 
SameAuthParamsLookupAutoClusterFailover fail fast when initialize(PulsarClient) 
is called more than once.
   - Remove the duplicate manual initialize call from 
SameAuthParamsLookupAutoClusterFailoverTest.testAutoClusterFailover because the 
provider is already initialized by PulsarClientBuilder.build().
   - Add dedicated tests that build a PulsarClient with each provider and then 
verify a second initialize(client) call throws IllegalStateException.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   ### Does this pull request potentially affect one of the following parts:
   
   - [ ] 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
   
   The threading model is affected only by preventing duplicate background 
failover check tasks from being registered for the same ServiceUrlProvider 
instance.
   


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