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

qiaojialin pushed a commit to branch rel/0.10
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/rel/0.10 by this push:
     new 7d96f85  [iotdb-832] fix sessionPool logic when reconnection failed. 
(#1611)
7d96f85 is described below

commit 7d96f8586c363038628bf5343eb34e6560e34b40
Author: Xiangdong Huang <[email protected]>
AuthorDate: Tue Aug 11 11:06:24 2020 +0800

    [iotdb-832] fix sessionPool logic when reconnection failed. (#1611)
    
    Co-authored-by: xiangdong huang <[email protected]>
---
 .../java/org/apache/iotdb/session/pool/SessionPool.java   | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git 
a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java 
b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
index 8221f6b..920b2d4 100644
--- a/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
+++ b/session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
@@ -115,10 +115,12 @@ public class SessionPool {
             //we have to wait for someone returns a session.
             try {
               this.wait(1000);
-              if (System.currentTimeMillis() - start > 60_000) {
+              long time = timeout < 60_000 ? timeout : 60_000;
+              if (System.currentTimeMillis() - start > time) {
                 logger.warn(
                     "the SessionPool has wait for {} seconds to get a new 
connection: {}:{} with {}, {}",
                     (System.currentTimeMillis() - start) / 1000, ip, port, 
user, password);
+                logger.warn("current occupied size {}, queue size {}, 
considered size {} ",occupied.size(), queue.size(), size);
                 if (System.currentTimeMillis() - start > timeout) {
                   throw new IoTDBConnectionException(
                       String.format("timeout to get a connection from %s:%s", 
ip, port));
@@ -139,7 +141,16 @@ public class SessionPool {
         logger.debug("Create a new Session {}, {}, {}, {}", ip, port, user, 
password);
       }
       session = new Session(ip, port, user, password, fetchSize);
-      session.open(enableCompression);
+      try {
+        session.open(enableCompression);
+      } catch (IoTDBConnectionException e) {
+        //if exception, we will throw the exception.
+        //Meanwhile, we have to set size--
+        synchronized (this) {
+          size --;
+        }
+        throw e;
+      }
       return session;
     }
   }

Reply via email to