mysqljs/mysql

Connections in pool have an infinite lifetime

開放

#1,276 建立於 2015年11月12日

 (8 則留言) (4 個反應) (0 位負責人)JavaScript (2,521 個分叉)batch import
help wanted

倉庫指標

星標
 (18,615 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

I have a process running all the time and when it idles for a while the connections in the pool are in a sleeping state. Eventually MySQL purges those connections based on the wait_timeout setting in my.cnf. Once this happens and I try to use a connection it will fail because the module assumes the connection is still live and tries to use it only to get a timeout or connection exception.

I would propose adding an option when creating a pool connection_lifetime which will work in a following way. When getting a connection from the pool, if the connection_lifetime is not exceeded we simply return the connection, if however it is exceeded we kill the selected free connection and create a new one in it's place. That should solve the issue.

貢獻者指南