shibd commented on code in PR #577:
URL: https://github.com/apache/pulsar-client-cpp/pull/577#discussion_r3256124989


##########
lib/ConsumerImpl.cc:
##########
@@ -371,8 +371,9 @@ Result ConsumerImpl::handleCreateConsumer(const 
ClientConnectionPtr& cnx, Result
         }
 
         if (consumerCreatedPromise_.isComplete()) {
-            // Consumer had already been initially created, we need to retry 
connecting in any case
+            // Clear the connection set before SUBSCRIBE so the next reconnect 
is not skipped.
             LOG_WARN(getName() << "Failed to reconnect consumer: " << 
strResult(result));
+            resetCnx();

Review Comment:
   I checked `ProducerImpl` as well. In the producer path, `connection_` is not 
set until `handleCreateProducer(..., ResultOk)` is called, so a failed 
reconnect `PRODUCER` response will not leave a stale connection that could 
cause `grabCnx()` to return early. The consumer path is different because 
`connectionOpened()` sets `connection_` before the broker confirms `SUBSCRIBE`. 
For this reason, the cleanup is intentionally kept in `ConsumerImpl`.
   
   I’ll merge this PR first. Letting the caller decide whether the connection 
needs to be reset makes the responsibility clearer.
   



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