shuwenwei commented on PR #162:
URL: https://github.com/apache/iotdb-client-go/pull/162#issuecomment-4774849940

   `conn.query` still installs the deferred `PutBack` before checking whether 
`GetSession` succeeded:
   
   ```go
   session, err := c.conn.GetSession()
   sessionReturned := false
   defer func() {
       if !sessionReturned {
           c.conn.PutBack(session)
       }
   }()
   if err != nil {
       release(c, err)
       return nil, err
   }
   ```
   
   This can hang on the error path. When `SessionPool.GetSession` fails while 
constructing a session, it already releases the semaphore token before 
returning the error. The deferred `PutBack` then runs with the zero-value 
`session`; `PutBack` still executes `<-spool.sem`, so it can block forever 
because the token has already been released.
   
   Please move the `sessionReturned`/defer block after the `err` check, so 
`PutBack` is only registered after a session was actually acquired.


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