shibd opened a new pull request, #577:
URL: https://github.com/apache/pulsar-client-cpp/pull/577

   ### Motivation
   
   A consumer can be created successfully and run for some time, then later 
reconnect after a broker restart, bundle unload, or topic ownership change. 
During that reconnect, `ConsumerImpl::connectionOpened()` sets `connection_` 
and registers the consumer before sending the broker `SUBSCRIBE` command.
   
   If that reconnect `SUBSCRIBE` is rejected, for example with an authorization 
error, `handleCreateConsumer()` treats the already-created consumer as 
retryable. However, the stale `connection_` remained set. The next reconnect 
timer then called `grabCnx()`, saw a non-null connection, returned early as 
"already connected", and stopped reconnecting. `isConnected()` could keep 
returning true because it only checks that `connection_` is non-null and the 
state is `Ready`, while broker stats show no active consumer.
   
   ### Changes
   
   - Clear the stale consumer connection when an already-created consumer fails 
to re-subscribe during reconnect.
   - Add a regression test that simulates a reconnect `SUBSCRIBE` rejection and 
verifies the stale connection is cleared and `isConnected()` returns false.
   - Expose the internal `handleCreateConsumer()` path through `PulsarFriend` 
for the regression test.
   
   ### Validation
   
   - `./build-support/docker-format.sh`
   - Attempted `./build/tests/pulsar-tests 
--gtest_filter=ConsumerTest.testIsConnectedFalsePositiveAfterSubscribeRejectedOnReconnect`,
 but the local Pulsar service was not running on `localhost:6650`, so the test 
timed out during initial subscribe before reaching the regression path.


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