Giter Club home page Giter Club logo

Comments (4)

zrlw avatar zrlw commented on June 2, 2024

如果不想那么麻烦,getConnection()判断closed为true时直接返回null,加上一行error日志输出能解决这个问题。
但是理论上要解决这个问题,DruidDataSource需要实现BeanPostProcessor接口且使用@Order注解确保在spring的ConfigurationPropertiesBindingPostProcessor前执行,DruidDataSource在postProcessBeforeInitialization方法设置druidDatasource开始初始化状态、在postProcessAfterInitialization方法设置完成初始化状态,然后在getConnection方法判断这个标识,如果是开始初始化的状态,直接返回null。
我觉得你可以提交个PR。

from druid.

whq4123 avatar whq4123 commented on June 2, 2024

发现有个不常用的属性 spring.cloud.refresh.never-refreshable 可以配置为 com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper 禁止 DruidDataSource 的动态属性刷新临时解决这个问题。
spring.cloud.refresh.never-refreshable = com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper

@zrlw assign 给我吧,尝试修复下

from druid.

zrlw avatar zrlw commented on June 2, 2024

@whq4123 我和你一样没有权限,不过PR并不需要指派,你可以直接提交的

from druid.

whq4123 avatar whq4123 commented on June 2, 2024

今天仔细看了下,我们用的druid 1.2.21版本,这个版本有个新增的逻辑是 DruidDataSourceWrapper实现了DisposableBean 接口,我认为这个改动有问题,也是问题出现的主要原因之一:
spring在rebind的时候(不光是nacos更新配置,不确定是否有其他情况)都会调用DisposableBean的destroy方法,如果按照现在的改动,rebind会导致close连接池,那所有的链接都会断开,cache都会清空,任务线程会中断,这显然是不合适的。所以这个地方应该还原为之前的代码。

from druid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.