BewareMyPower commented on PR #1323:
URL: 
https://github.com/apache/pulsar-client-go/pull/1323#issuecomment-2565474314

   Yes, the consumer's connection is called after the Subscribe RPC is done. 
   
   When a partition consumer (`pc`) receives a `CLOSE_CONSUMER` command,
   1. In `connection.handleCloseConsumer`, it calls 
`consumer.ConnectionClosed(closeConsumer)`, which sends a `connectionClosed` 
event to `pc.connectCloseCh`.
   2. In `pc.runEventsLoop`, `reconnectToBroker` is called, **all** requests 
sent via `pc._getConn()` will wait until this method is done.
   
   What I have concern is, before the `reconnectToBroker` is done, the 
`pc._getConn()` will return a non-nil outdated connection. If `_getConn()` is 
not called in `runEventsLoop()`, it might return an outdated connection.
   
   There is another possible case that `internalXxx` could be called before 
`reconnectToBroker` is called, i.e. `pc.eventsCh` receives an event before 
`pc.connectClosedCh`.
   
   Ideally, I think the best solution is to call `pc._setConn(nil)` before 
sending the `connectionClosed` event in `ConnectionClosed` and check if 
`_getConn` is nil in `RequestOnCnx` or `RequestOnCnxNoWait`.


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