接hikari连接池报cannot be called on a closed connection bug

异常描述:
立马报错,没有等待超时等现象!
异常信息:

Caused by: java.sql.SQLSyntaxErrorException: (conn=524293) Connection.setNetworkTimeout cannot be called on a closed connection
	at com.oceanbase.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:110)
	at com.oceanbase.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:211)
	at com.oceanbase.jdbc.OceanBaseConnection.setNetworkTimeout(OceanBaseConnection.java:2121)
	at com.zaxxer.hikari.pool.PoolBase.setNetworkTimeout(PoolBase.java:566)
	at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:432)
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369)
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
	... 6 more

用的依赖版本:

<dependency>
    <groupId>com.oceanbase</groupId>
    <artifactId>oceanbase-client</artifactId>
    <version>2.4.0</version>
</dependency>

<dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>4.0.3</version>
    </dependency>

Ocean版本:
5.7.25-OceanBase_CE-v4.0.0.0

这个报错是偶现还是必现的,连接的是什么类型的租户?oracle or mysql

必现的,什么类型的租户啥意思呢,我给你发下Ocean版本信息:5.7.25-OceanBase_CE-v4.0.0.0

可以抓下包吗,我们这边分析一下,在应用机器对访问数据库端口抓包就ok。


[root@test ~]# tcpdump -i eth0 port 2883
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
15:11:40.381088 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 2222729990, win 237, length 0
15:11:40.460641 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:11:45.460076 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 1, win 237, length 0
15:11:45.528989 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:11:50.529092 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 1, win 237, length 0
15:11:50.593601 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:11:55.593103 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 1, win 237, length 0
15:11:55.654289 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:12:00.654091 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 1, win 237, length 0
15:12:00.710855 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:12:04.368631 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [S], seq 2700164691, win 64240, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
15:12:04.368819 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [S.], seq 893214998, ack 2700164692, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0
15:12:04.430560 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:12:04.432813 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [P.], seq 1:79, ack 1, win 229, length 78
15:12:04.512874 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [P.], seq 1:353, ack 79, win 1026, length 352
15:12:04.512915 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [.], ack 353, win 237, length 0
15:12:04.516868 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [P.], seq 79:121, ack 353, win 237, length 42
15:12:04.634719 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [.], ack 121, win 1026, length 0
15:12:04.655681 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [P.], seq 353:463, ack 121, win 1026, length 110
15:12:04.657693 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [P.], seq 121:169, ack 463, win 237, length 48
15:12:04.717168 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [P.], seq 463:517, ack 169, win 1025, length 54
15:12:04.718062 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [P.], seq 169:217, ack 517, win 237, length 48
15:12:04.779015 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [P.], seq 517:712, ack 217, win 1025, length 195
15:12:04.779841 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [P.], seq 217:574, ack 712, win 245, length 357
15:12:04.883114 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [.], ack 574, win 1024, length 0
15:12:04.903747 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [P.], seq 712:809, ack 574, win 1024, length 97
15:12:04.904519 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [P.], seq 574:902, ack 809, win 245, length 328
15:12:04.965152 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [P.], seq 809:849, ack 902, win 1023, length 40
15:12:04.966565 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [F.], seq 902, ack 849, win 245, length 0
15:12:05.026881 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [.], ack 903, win 1023, length 0
15:12:05.026974 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [F.], seq 889, ack 903, win 1023, length 0
15:12:05.026980 IP 172.18.1.7.cambertx-lm > test.ndnp: Flags [P.], seq 849:889, ack 903, win 1023, length 40
15:12:05.027181 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [R], seq 893215901, win 0, length 0
15:12:05.027205 IP test.ndnp > 172.18.1.7.cambertx-lm: Flags [R], seq 893215901, win 0, length 0
15:12:05.710064 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 1, win 237, length 0
15:12:05.777095 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:12:10.777160 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 1, win 237, length 0
15:12:10.855132 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0
15:12:15.855083 IP test.ndnp > 172.18.1.7.mtqp: Flags [.], ack 1, win 237, length 0
15:12:15.924741 IP 172.18.1.7.mtqp > test.ndnp: Flags [.], ack 1, win 1026, length 0

这个行吗

tcpdump -i eth0 port 2883 -vvv -w ob.cap
把文件发一下

ob.zip (2.5 KB)

好的,我们这边先分析看看

你这环境是怎么部署的?

可以发下,HikariCP的版本,OBProxy和OBserver的版本吗?

docker部署的,镜像:obpilot/oceanbase-ce
连接池:

<dependency>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP</artifactId>
      <version>4.0.3</version>
      <scope>provided</scope>
  </dependency>

你好,我这边hikari4.0.3+oceanbase-client2.4.0初步验证下来mysql/oracle租户均未出现上方堆栈的cannot be called on a closed connection这种情况,能否提供更多信息,例如hikari以及oceanbase参数配置情况以及具体执行的sql

        HikariConfig config = new HikariConfig();
        config.setJdbcUrl(jdbcUrl);
        config.setUsername(userName);
        config.setPassword(password);
        config.setMinimumIdle(10);
        config.setMaximumPoolSize(100);
        config.setConnectionTimeout(30000);
        config.setMaxLifetime(12000);

收到,内部正在复查,有结论会及时反馈,谢谢~

useOceanBaseProtocolV20=false 加上这个参数可以解决这个问题