You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2020/08/10 16:21:07 UTC
[incubator-iotdb] 01/01: [iotdb-832] fix sessionPool logic when
reconnection failed.
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch iotdb-832
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 23d706110a63aafa1e5dbdea55a4eccefcd7d1e6
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Tue Aug 11 00:20:31 2020 +0800
[iotdb-832] fix sessionPool logic when reconnection failed.
---
.../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 4a03917..d50a12e 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;
}
}