This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch fixBugs-0326
in repository https://gitbox.apache.org/repos/asf/iotdb-client-go.git

commit 81fe8335c2aa89a9bfe28b47485553b04e46213c
Author: shuwenwei <[email protected]>
AuthorDate: Thu Feb 26 17:13:48 2026 +0800

    Fix multiple issues in SessionPool and PooledTableSession (#153)
---
 client/sessionpool.go | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/client/sessionpool.go b/client/sessionpool.go
index 48b322a..a05cc4e 100644
--- a/client/sessionpool.go
+++ b/client/sessionpool.go
@@ -83,7 +83,10 @@ func (spool *SessionPool) GetSession() (session Session, err 
error) {
                                }
                        default:
                                config := spool.config
-                               session, err := spool.ConstructSession(config)
+                               session, err = spool.ConstructSession(config)
+                               if err != nil {
+                                       <-spool.sem
+                               }
                                return session, err
                        }
                case <-time.After(time.Millisecond * 
time.Duration(spool.waitToGetSessionTimeoutInMs)):
@@ -137,12 +140,33 @@ func getClusterSessionConfig(config *PoolConfig) 
*ClusterConfig {
 }
 
 func (spool *SessionPool) PutBack(session Session) {
-       if session.trans.IsOpen() {
+       defer func() {
+               if r := recover(); r != nil {
+                       session.Close()
+               }
+       }()
+       if session.trans != nil && session.trans.IsOpen() {
                spool.ch <- session
        }
        <-spool.sem
 }
 
+func (spool *SessionPool) dropSession(session Session) {
+       defer func() {
+               if e := recover(); e != nil {
+                       if session.trans != nil && session.trans.IsOpen() {
+                               session.Close()
+                       }
+               }
+       }()
+       err := session.Close()
+       if err != nil {
+               log.Println("Failed to close session ", session)
+       }
+       <-spool.sem
+}
+
+>>>>>>> f00cf99 (Fix multiple issues in SessionPool and PooledTableSession 
(#153))
 func (spool *SessionPool) Close() {
        close(spool.ch)
        for s := range spool.ch {

Reply via email to