-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
Updated connection cleanup process to handle expired connections and those exceeding config.maxIdle
#3022
Updated connection cleanup process to handle expired connections and those exceeding config.maxIdle
#3022
Conversation
…hat have expired as well as the connections that exceed the config.maxIdle setting
776563e
to
e9f2366
Compare
Thanks for the PR and the detailed reports and explanations, @robert-pitt-foodhub 🤝 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3022 +/- ##
=======================================
Coverage 88.13% 88.13%
=======================================
Files 71 71
Lines 12889 12890 +1
Branches 1352 1354 +2
=======================================
+ Hits 11360 11361 +1
Misses 1529 1529
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…even when below maxIdle
Thanks @wellwelwel, Happy to help get this bug resolved, I have made another commit to the PR to add a new test case that specifically validates the connections are removed after. they are expired, let me know if there is any other test cases you would like me to address or documentation that needs updating. Thanks |
@robert-pitt-foodhub, although the changes to the code are relatively simple, this seems a complex behavior to reproduce in a test case. I tried removing your changes, keeping your test, but it didn't fail even with the current logic. |
Hey @wellwelwel, here's a failing test case that fail on the main branch but pass with the new code, Let me know if this helps
|
Thanks @robert-pitt-foodhub, I believe this last test is the ideal 🙋🏻♂️ |
Would you like to to add this test to the PR test cases @wellwelwel |
For fixes, it's usually helpful to have a test that expects a failure to ensure that a new change doesn't break again in the future 🙋🏻♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pool isn't being closed 🙋🏻♂️
LGMT Thanks again, @robert-pitt-foodhub 🤝 |
Im happy for to you merge this yes, there is one other outstanding change which I think needs to be addressed which I noted in the Issue, but that we can deal with separately if you like. Thanks for your support as well, go ahead and merge when your ready |
Description
This PR addresses issue #3020 by improving the connection cleanup process in the MySQL pool. The changes ensure that both connections exceeding the
config.maxIdle
setting and expired idle connections (those exceeding theconfig.idleTimeout
) are correctly cleaned up.Summary of changes:
lib/pool.js
config.maxIdle
and expired connections based onconfig.idleTimeout
.New tests:
test-pool-release-idle-connection-timeout.test.cjs
to verify the removal of idle connections after the timeout period.test-pool-release-idle-connection.test.cjs
to reflect the new cleanup behaviour.Key Changes:
lib/pool.js
.test-pool-release-idle-connection-timeout.test.cjs
).Checklist
idleTimeout
,maxIdle
)How to Test
Create a pool with the following settings:
connectionLimit: 3
maxIdle: 1
idleTimeout: 5000
(5 seconds)Open and release 3 connections.
Ensure connections are removed after 5 seconds if idle.
Run the provided integration tests (
npm test
or equivalent).Linked Issues
Screenshots (if applicable)
See linked issue