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
MySQL keeps re-establishing connections #520
Comments
RBatis version: 4.5.19 Our business may update the MySQL database dozens of times per second, and multiple tasks will initiate updates concurrently. Now I use system tools to observe TCP connections and find that every few tens of seconds, the TCP connections between the application and MySQL will be replaced. The system also sees that a large number of TCP connections are in the TIMEWAIT state. Questions to ask:
Thanks |
RBatis 默认是以连接池工作的,就是说Table::insert(&rb) 的时候rb实际上是连接池对象的引用(从连接池随机获取和创建)。 //提前新建连接,而不是从连接池随机获取和创建
let conn = rb.acquire().await?;
loop{
Table::insert(&conn).await?;
} |
RBatis works with a connection pool by default, which means that when Table::insert(&rb) is used, rb is actually a reference to the connection pool object (randomly obtained and created from the connection pool). //Create a new connection in advance instead of randomly obtaining and creating it from the connection pool
let conn = rb.acquire().await?;
loop{
Table::insert(&conn).await?;
} |
谢谢你的回复。 我的理解调用 acquire 后,当前任务会独占一个连接。 有没有办法让连接不要一直重建,如果所有的连接都被占用了,让新发起的调用排队等待。 |
Thank you for your reply. My understanding is that after calling acquire, the current task will exclusively own a connection. Is there a way to not keep re-establishing connections, but to have newly initiated calls queued up if all connections are occupied. |
RBatis 版本:4.5.19
mysql: 5.7
我们的业务每秒钟可能更新 MySQL 数据库几十次,多个任务会并发发起更新。
现在通过系统工具观察 TCP 连接,发现每过几十秒钟,应用跟 MySQL 的 TCP 连接,就会更换一批,系统也看到大量的 TCP 连接处在 TIMEWAIT 状态。
请教的问题:
谢谢
The text was updated successfully, but these errors were encountered: