8000 修复DruidDataSource close后CreateConnectionThread没有退出的问题 by htynkn · Pull Request #3881 · alibaba/druid · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

修复DruidDataSource close后CreateConnectionThread没有退出的问题 #3881

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

Merged
merged 2 commits into from
Oct 6, 2020
Merged

Conversation

htynkn
Copy link
Contributor
@htynkn htynkn commented Jul 22, 2020

问题描述:
mysql主从,当主库hang住以后获取链接超时,此时进行主从切换,调用DruidDataSource的close方法并重新创建新的DruidDataSource。新的DruidDataSource正确链接了正确的数据库,但是原来的DruidDataSource中CreateConnectionThread并没有退出,还在持续尝试创建链接,进而报错。

分析:
DruidDataSource中的CreateConnectionThread和DestroyConnectionThread是成对出现的,调用close方法会采用中断方式关闭它们。而目前观测到的情况是DestroyConnectionThread退出,但是CreateConnectionThread没有。对比二者逻辑,DestroyConnectionThread包含Thread.isInterrupted检测,但是CreateConnectionThread中调用createPhysicalConnection方法时没有处理interruptedException。mysql hang住时,超时时间一般都是秒级别的,导致close时基本100%停留在此处,故catch了SQLException后没有退出。

变更:
CreateConnectionThread中增加closed closing判断,如果觉得不妥,也可以使用Thread.isInterrupted

类似问题 #2291

@CLAassistant
Copy link
CLAassistant commented Jul 22, 2020

CLA assistant check
All committers have signed the CLA.

@wenshao wenshao merged commit fce4f37 into alibaba:master Oct 6, 2020
wenshao added a commit that referenced this pull request Oct 6, 2020
@htynkn htynkn deleted the patch-1 branch October 6, 2020 14:19
@ljwps
Copy link
ljwps commented Nov 4, 2020

请问这个解决了么,我今天更新了1.2.2这个问题依然存在

@Colin-debugIO
Copy link

2022年了,这个好像还没解决
#4196

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 this pull request may close these issues.

5 participants
0