This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new 05aeab1de56 [To dev/1.3] Cherry pick session connection leak fixes
(#16808)
05aeab1de56 is described below
commit 05aeab1de566d84141ba1a24f1df13dbf4b167f8
Author: Haonan <[email protected]>
AuthorDate: Wed Nov 26 15:10:25 2025 +0800
[To dev/1.3] Cherry pick session connection leak fixes (#16808)
* Fix Session reconnection increase connection number (#15677)
* Fix Session reconnection increase connection number
* Fix Session reconnection increase connection number
* Optimize the implement
* Fix SessionConnection opens too much transport without closing (#15649)
---
.../java/org/apache/iotdb/session/SessionConnection.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
index bee82eb2f14..baa30e84131 100644
---
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
+++
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
@@ -160,6 +160,9 @@ public class SessionConnection {
DeepCopyRpcTransportFactory.setDefaultBufferCapacity(session.thriftDefaultBufferSize);
DeepCopyRpcTransportFactory.setThriftMaxFrameSize(session.thriftMaxFrameSize);
try {
+ if (transport != null && transport.isOpen()) {
+ close();
+ }
if (useSSL) {
transport =
DeepCopyRpcTransportFactory.INSTANCE.getTransport(
@@ -956,7 +959,18 @@ public class SessionConnection {
if (session.endPointToSessionConnection == null) {
session.endPointToSessionConnection = new ConcurrentHashMap<>();
}
- session.endPointToSessionConnection.put(session.defaultEndPoint, this);
+ session.endPointToSessionConnection.compute(
+ session.defaultEndPoint,
+ (k, v) -> {
+ if (v != null && v.transport != null && v.transport.isOpen()) {
+ try {
+ v.close();
+ } catch (IoTDBConnectionException e) {
+ logger.warn("close connection failed, {}", e.getMessage());
+ }
+ }
+ return this;
+ });
break;
}
}