Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] connection disabled #6050

Open
dujiaolianglong opened this issue Jul 19, 2024 · 2 comments · May be fixed by #6143
Open

[BUG] connection disabled #6050

dujiaolianglong opened this issue Jul 19, 2024 · 2 comments · May be fixed by #6143

Comments

@dujiaolianglong
Copy link

dujiaolianglong commented Jul 19, 2024

Database Type

Postgresql

Database Version

Druid Version

1.2.4

JDK Version

JDK8

Error SQL

Testcase Code

No response

Stacktrace Info

Caused by: java.sql.SQLException: connection disabled
at com.alibaba.druid.pool.DruidPooledConnection.checkStateInternal(DruidPooledConnection.java:1170) ~[druid-1.2.4.jar:1.2.4]
at com.alibaba.druid.pool.DruidPooledConnection.checkState(DruidPooledConnection.java:1155) ~[druid-1.2.4.jar:1.2.4]
at com.alibaba.druid.pool.DruidPooledConnection.setAutoCommit(DruidPooledConnection.java:703) ~[druid-1.2.4.jar:1.2.4]
at org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.begin(AbstractLogicalConnectionImplementor.java:72) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
... 95 more
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:719) ~[gsjdbc4-V100R003C10SPC120B100.jar:?]
at org.postgresql.jdbc2.AbstractJdbc2Connection.rollback(AbstractJdbc2Connection.java:736) ~[gsjdbc4-V100R003C10SPC120B100.jar:?]

Error Info

报错如下

Caused by: java.sql.SQLException: connection disabled
at com.alibaba.druid.pool.DruidPooledConnection.checkStateInternal(DruidPooledConnection.java:1170) ~[druid-1.2.4.jar:1.2.4]
at com.alibaba.druid.pool.DruidPooledConnection.checkState(DruidPooledConnection.java:1155) ~[druid-1.2.4.jar:1.2.4]
at com.alibaba.druid.pool.DruidPooledConnection.setAutoCommit(DruidPooledConnection.java:703) ~[druid-1.2.4.jar:1.2.4]
at org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.begin(AbstractLogicalConnectionImplementor.java:72) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
... 95 more
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:719) ~[gsjdbc4-V100R003C10SPC120B100.jar:?]
at org.postgresql.jdbc2.AbstractJdbc2Connection.rollback(AbstractJdbc2Connection.java:736) ~[gsjdbc4-V100R003C10SPC120B100.jar:?]

连接池配置如下

druid.initialSize=10
druid.maxActive=1000
druid.minIdle=50
druid.validationQuery=select 1
druid.testWhileIdle=true
druid.timeBetweenEvictionRunsMillis=10000
druid.minEvictableIdleTimeMillis=300000
druid.testOnBorrow=false
druid.testOnReturn=false

自定定位情况

看了获取连接的代码
连接已经获取到了,然后再hibernate开启事务时校验连接时报错”connection disabled“
从代码可以看出,先判断了 连接的状态,应该是判断到连接未关闭,但是开启事务时,发现druid维持的连接状态为disabled状态

疑问

这个问题在后续某个版本修复了吗?是在哪个版本修复的?
又或者 我的druid配置不当?

@taodamiao
Copy link

请问解决了吗?我也遇到了。

@linghengqian
Copy link

  • I have opened Add property closeConnOnFatalError to match HikariCP's behavior #6143 .
  • By setting closeConnOnFatalError to false, Druid's behavior will align with HikariCP, that is, the connection will no longer be closed when a fatal error defined by Druid occurs. This solves a series of controversies surrounding Hibernate, Flyway, and ShardingSphere. This is a huge regret introduced from 882470b 7 years ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants