wenbingshen commented on a change in pull request #677:
URL: https://github.com/apache/pulsar-client-go/pull/677#discussion_r762407552



##########
File path: pulsar/internal/connection.go
##########
@@ -858,13 +858,14 @@ func (c *connection) Close() {
                c.Lock()
                cnx := c.cnx
                c.Unlock()
-               c.changeState(connectionClosed)
+               c.changeState(connectionClosing)

Review comment:
       If there is no intermediate `connectionClosing` state, other threads may 
start to create new connections in `GetConnection` before the current `cnx` is 
really closed. This is a mistake in itself. State transitions should be 
stricter. You can see that the network connection state transition of the java 
client is very rigorous.
   
   If we can ensure that the state transition is more rigorous, set the state 
to `connectionClosing` before `cnx`  closed, which can prevent other threads to 
create a new connection. This may be able to solve the issue #676 that the old 
connection was not closed, and the new connection has initiated a request, even 
if this is not the root cause of the problem.




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