-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Pool connections are not gracefully closed once idle connection cleanup occurs. #3148
Comments
Reproduce script:
|
The issue also occurs in latest MySQL:
|
Hello, I have submitted a new pull request (#3180) that addresses this issue with minimal changes. In my view, an improved long-term solution would involve removing the deprecation warning, as it has been in place for some time, and implementing proper end functionality in pool_connection without relying on _realEnd. If you would like me to work on this enhancement, I would be happy to update the pull request accordingly. Best regards, |
Upon further consideration, it seems more appropriate to implement proper end functionality directly within pool_connection, as the current fix could be susceptible to unexpected edge cases. For example, when using the _realEnd function, the connection is removed from the pool upon the "end" event, which can create a brief window during which a closed connection might still be allocated. |
Hi,
When Pool._removeIdleTimeoutConnections() is executed and an idle connection is selected for removal (regardless of the conditions) the following code is executed:
https://github.com/sidorares/node-mysql2/blob/master/lib/pool.js#L208
This in turn removes the connection from the pool and directly (non-gracefully) closes it by calling PoolConnection.destroy() instead of PoolConnection.end().
https://github.com/sidorares/node-mysql2/blob/master/lib/pool_connection.js#L50
As a result the connection is closed without notifying the server in any way.
Because of the above the SQL(MariaDB) server is flooded with warnings like:
Aborted connection 123 to db: 'dbname' user: 'dbuser' host: '127.0.0.1' (Got an error reading communication packets)
A possible solution might be to change the current PoolConnection.end() implementation with:
but I'm not sure if this solves the issue correctly.
Looking forward to your thoughts on this.
The text was updated successfully, but these errors were encountered: