-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Database connection is not correctly destroyed after knex 0.12.2 #1973
Comments
Based on the changelog I would guess #1731 causes this in some way. Some changes to Edit: Testing with postgres, I'm unable to reproduce the issue as described, while switching between versions 0.12.2 -> 0.12.7. Viewing the PG server status, the connections appear to close properly and returns to the pool in both versions. The process does not exit in either version. const db = require('knex')({...});
db
.transaction((tr) => tr('user').select())
.then(() => db.destroy())
.then(() => console.log('Destroyed'));
//No open connections in server status |
I have tested with MySQL only. Tested multiple |
I debugged. This timeout https://github.com/tgriesser/knex/blob/master/src/client.js#L234 is blocking the process to exit. |
https://github.com/tgriesser/knex/blob/master/src/client.js#L243 If an error occurs, shouldn't the timeout be cleared? |
@kirrg001 Ah yes, makes sense the timeout would cause the process not to exit, but it also makes sense why @tgriesser added it. In order to properly release connections back to the pool, the two handlers must be seperate for I agree Does your app's process "eventually" exit, or does it idle beyond Unfortunately I don't have an answer to this problem right now. Will try look into this some more. |
It exits after the timeout. My use case is a bit complex and 3 database connections are created, one of these connections can throw an error at the moment if the database does not exist, knex tries to acquire a connection to this target database and fails. That's why clearing the timeout solves this issue for me. Thanks for your fast support here. |
@kirrg001 I see, I thought your app remained idle eventhough all attempts of acquiring connections were successful, but I understand now that's not the case. I'll merge this in right now, definitely a bug. Thanks for the report! |
…, even if an error occurs. Fixes knex#1973
@kirrg001 FYI: Pushed 0.12.8 |
Thanks so much 🐩 |
closes #59 - minimum knex version is 0.12.8 - see knex/knex#1973
Hey 👋
I have recently updated knex from
0.12.2
to0.12.7
and noticed that the database connection is not closed when callingconnection.destroy
. The result is, that a process doesn't exit.Here is a snippet:
NOTE: debug('Destroyed connection') get's called.
I have tested all knex versions and it starts in
0.12.3
.The code works for me with
0.12.2
, but does not with0.12.3
.Is there anything i can change in my code to get it working with >
0.12.2
?Otherwise, I went through the changes, maybe related to the pool update #1702?
Thank you so much!
Kate
The text was updated successfully, but these errors were encountered: