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

数据库连接池无法获取连接 #161

Closed
chanlk opened this issue May 17, 2022 · 11 comments
Closed

数据库连接池无法获取连接 #161

chanlk opened this issue May 17, 2022 · 11 comments

Comments

@chanlk
Copy link

chanlk commented May 17, 2022

版本:1.9 RELEASE
最近程序跑得好好的会突然出现所有接口都无响应的情况,排查之后发现只要用到了Mysql的接口才有问题;

用Arthas工具查了查连接池,一个idle连接都没有了;
image

ReactorNettyClient 类
image

另外日志上有这个日志:
[dev.miku.r2dbc.mysql.client.MessageDuplexCodec.channelInactive][136] [Connection has been closed by peer]

我做过的尝试

  1. 在Mysql用Show processlist列出所有jetlinks的连接,然后直接将连接Kill了(Kill Processid)
  2. 此时执行查询接口,应用会出错并打印错误日志,同时也有打印 [Connection has been closed by peer]
  3. 但是过一会儿连接就重新建立了(show processlist可以看到),程序也恢复正常

我的猜测

在mysql驱动和pool的github issues上都有类似的pool挂了的问题,似乎还没有被最终解决,驱动作者应该在忙着其他事情;
issues 链接如下:
mirromutth/r2dbc-mysql#82

不知老周有没有遇到此问题,感谢解惑~
PS: 老周代码功力真强!

@zhou-hao
Copy link
Member

@chanlk
Copy link
Author

chanlk commented May 17, 2022

谢谢!
不过这个配置是怎么解决问题的呢,看起来就是指定了一些连接池的参数

@zhou-hao
Copy link
Member

通过设置连接有效期,让连接在超过有效期后自动断开。

@chanlk
Copy link
Author

chanlk commented May 17, 2022

指的是max-life-time吗,在yml中我有配置r2dbc.pool.max-life-time,设置的是5分钟
还是指的max-idle-time?这个也有设置的,是2分钟

image

@zhou-hao
Copy link
Member

max-life-time, 这个配置在spring-boot 2.3.x 是不生效的。

@chanlk
Copy link
Author

chanlk commented May 17, 2022

感谢!
这个链接可以说明确实是2.4.x 才支持
spring-projects/spring-boot#21219

另外我看了下连接确实lifeTime很大
image

我增加配置后重新部署一下,如果14天内问题不再发生,我就将此issue关闭!

@chanlk
Copy link
Author

chanlk commented May 20, 2022

增加配置后,问题仍然出现,liftTime已经生效,为配置文件的默认值 10分钟。
更新了reactor-core版本,再上线观察

@zhou-hao
Copy link
Member

现在情况如何

@FreedomOFO
Copy link

https://github.com/jetlinks/jetlinks-community/tree/master/jetlinks-components/configure-component/src/main/java/org/jetlinks/community/configure/r2dbc 看这里。把这个配置复制到你的代码。

遇到了相似的问题,这个配置的链接已经失效,能麻烦再把配置给出来吗

@zhou-hao
Copy link
Member

最新master分支直接配置 spring.r2dbc.pool.max-life-time即可

@yuchunyi
Copy link

增加配置后,问题仍然出现,liftTime已经生效,为配置文件的默认值 10分钟。 更新了reactor-core版本,再上线观察

你好,你遇到的问题解决了没

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

No branches or pull requests

4 participants