Skip to content

Conversation

@shilei1987
Copy link

数据源获取物理连接的时候,如果出现RuntionException,由于是会不停的申请数据库物理连接,会导致物理连接申请成功,但是由于RuntimeException不能正确的返回DruidSource的连接,从而导致数据库连接被迅速占用完

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


shilei seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@kimmking
Copy link
Collaborator

kimmking commented Mar 3, 2023

具体是什么原因导致的不断重复抛异常呢?

@zrlw
Copy link
Contributor

zrlw commented Dec 18, 2023

执行单元测试MySqlHexTest就能看到死循环效果:

Caused by: java.net.UnknownHostException: hbase-01
	at java.net.InetAddress.getAllByName0(InetAddress.java:1281)
	at java.net.InetAddress.getAllByName(InetAddress.java:1193)
	at java.net.InetAddress.getAllByName(InetAddress.java:1127)
	at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:130)
	at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63)
	... 9 more

原因是MySqlHexTest测试类配置的jdbcUrl是jdbc:mysql://hbase-01:3306/sonar,而测试环境并没有配置hbase-01的ip地址。
建议借鉴这个PR的做法,把RunTime异常和SQL异常处理合并,如果一次连接都没有创建成功过,就break中止,否则按原来SQL异常处理分支处理。

@codedad1983
Copy link

@zrlw 你提出的场景与 @shilei1987 描述的问题完全不是一码事。测试环境并没有配置hbase-01的ip地址并不会导致真是物理连接被创建,也不存在消耗数据库连接的问题。如此修改这个创建过程逻辑导致我们应用在启动刚开始的故障自恢复能力完全失效。

lizongbo added a commit to lizongbo/druid that referenced this pull request Mar 14, 2024
lizongbo added a commit that referenced this pull request Mar 14, 2024
回退相关测试用例 #5771  #4885
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants