在 Apache IoTDB 中使用 sessionPool 时出现 IoTDBConnectionException 错误
IoTDBConnectionException Error when using sessionPool in Apache IoTDB
这是我的配置:
MAVEN 依赖项:
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-session</artifactId>
<version>0.12.0</version>
</dependency>
会话池配置:
@Configuration
public class IotDbConfig {
@Bean
public SessionPool sessionPool() {
int maxsize = 20;
return new SessionPool(
"127.0.0.1",
6667,
"root",
"root",
maxsize);
}
}
单线程执行该方法20次:
public SessionDataSetWrapper executeSql(String sql) throws IoTDBConnectionException, StatementExecutionException {
return sessionPool.executeQueryStatement(sql);
}
这里是错误:
15:35:15.194 [http-nio-8080-exec-1] WARN o.a.i.s.p.SessionPool - [getSession,244] - the SessionPool has wait for 60 seconds to get a new connection: 127.0.0.1:6667 with root, root
15:35:15.194 [http-nio-8080-exec-1] WARN o.a.i.s.p.SessionPool - [getSession,251] - current occupied size 20, queue size 0, considered size 20
org.apache.iotdb.rpc.IoTDBConnectionException: timeout to get a connection from 127.0.0.1:6667
at org.apache.iotdb.session.pool.SessionPool.getSession(SessionPool.java:258)
at org.apache.iotdb.session.pool.SessionPool.executeQueryStatement(SessionPool.java:1099)
at com.ruoyi.common.utils.IotDBUtils.getTimeseries(IotDBUtils.java:35)
at com.ruoyi.system.service.impl.IotDBServiceImpl.getDeviceData(IotDBServiceImpl.java:49)
at com.ruoyi.web.controller.device.DeviceController.deviceData(DeviceController.java:67)
...
我该如何解决?我使用的是 0.12.0 版本
您可以使用 pool.closeResultSet(wrapper)
关闭查询结果集,并 return 将查询 link 放入会话池。我们建议您使用版本 0.12.3,它解决了这个问题和其他一些安全问题:)
这是我的配置: MAVEN 依赖项:
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-session</artifactId>
<version>0.12.0</version>
</dependency>
会话池配置:
@Configuration
public class IotDbConfig {
@Bean
public SessionPool sessionPool() {
int maxsize = 20;
return new SessionPool(
"127.0.0.1",
6667,
"root",
"root",
maxsize);
}
}
单线程执行该方法20次:
public SessionDataSetWrapper executeSql(String sql) throws IoTDBConnectionException, StatementExecutionException {
return sessionPool.executeQueryStatement(sql);
}
这里是错误:
15:35:15.194 [http-nio-8080-exec-1] WARN o.a.i.s.p.SessionPool - [getSession,244] - the SessionPool has wait for 60 seconds to get a new connection: 127.0.0.1:6667 with root, root
15:35:15.194 [http-nio-8080-exec-1] WARN o.a.i.s.p.SessionPool - [getSession,251] - current occupied size 20, queue size 0, considered size 20
org.apache.iotdb.rpc.IoTDBConnectionException: timeout to get a connection from 127.0.0.1:6667
at org.apache.iotdb.session.pool.SessionPool.getSession(SessionPool.java:258)
at org.apache.iotdb.session.pool.SessionPool.executeQueryStatement(SessionPool.java:1099)
at com.ruoyi.common.utils.IotDBUtils.getTimeseries(IotDBUtils.java:35)
at com.ruoyi.system.service.impl.IotDBServiceImpl.getDeviceData(IotDBServiceImpl.java:49)
at com.ruoyi.web.controller.device.DeviceController.deviceData(DeviceController.java:67)
...
我该如何解决?我使用的是 0.12.0 版本
您可以使用 pool.closeResultSet(wrapper)
关闭查询结果集,并 return 将查询 link 放入会话池。我们建议您使用版本 0.12.3,它解决了这个问题和其他一些安全问题:)