Open ltylty opened 4 years ago
实测最新版本1.2.1仍有该问题,怀疑是当之前的SQL语句执行出现SQLException时,druid会做处理,使得后续的连接会直接disabled 从而导致这个问题
同样遇到这个问题,通过分析debug后,发现引起这问题的原因是druid的ExceptionSorter设计;
无权限SQL执行时 SELECT command denied to user '' for table 'user_variables_by_thread
MYSQL返回ErrorCode:1142
https://github.com/alibaba/druid/blob/master/src/main/java/com/alibaba/druid/pool/vendor/MySqlExceptionSorter.java
进行处理 case 1142,isExceptionFatal 为true的话,会进行handleFatalError的处理 discard connection。
ping
2000个issue 没人处理,阿里是放弃了这个连接池了吧?
change to version flyway 5.2.1
and try again.
I found another solution to solve this issue when you use druid and flyway after 5.2.1 version.
You can configure the flyway.url, and then flyway will not use the datasource which provide by druid, however, it will create mysql connection, and then the problems will be solved.
spring:
flyway:
enabled: true
# 自己定义url不会使用druid自带的连接池,可以防止flyway 5.2.1以后需要performance_schema的问题
url: jdbc:mysql://localhost:3306/BigData?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
user: testUser
password: testUser@2023
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 https://github.com/alibaba/druid/commit/882470b1ce7a51a94f3525beceec91384ccd425f 7 years ago.
spring boot 2.2, flyway 6.0.8.
related issue https://github.com/flyway/flyway/issues/2215 https://github.com/flyway/flyway/issues/2240