Skip to content
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

Dispose closed pool connections #260

Merged
merged 5 commits into from Nov 26, 2023

Conversation

nehzata
Copy link
Contributor

@nehzata nehzata commented Nov 24, 2023

In some cases the connection gets closed after a query is executed without throwing an error. This patch checks to see if the connection has been closed and disposes of it.

steps to replicate:

final conn = Pool.withEndpoints(....);
await conn.execute('-- test'); // this doesn't throw but it causes the connection to close
await conn.execute('select true'); // this throws because the pool picks up the previously closed connection. a PgException(Severity.error Connection is closing down) error is thrown. 

@isoos
Copy link
Owner

isoos commented Nov 25, 2023

Thanks, looks good! Would you happen to have time to also update the changelog and maybe add a test case for this?

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4240b5d) 85.73% compared to head (daa9d57) 85.77%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #260      +/-   ##
==========================================
+ Coverage   85.73%   85.77%   +0.04%     
==========================================
  Files          25       25              
  Lines        2215     2215              
==========================================
+ Hits         1899     1900       +1     
+ Misses        316      315       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nehzata
Copy link
Contributor Author

nehzata commented Nov 25, 2023

@isoos Thanks for the quick response. PR updated. Let me know if anything else is needed.

@nehzata
Copy link
Contributor Author

nehzata commented Nov 26, 2023

Nice! Thanks @isoos. Apologies I was in a rush with the kids. Appreciate your help.

@isoos isoos merged commit b4d97fb into isoos:master Nov 26, 2023
1 check passed
@isoos
Copy link
Owner

isoos commented Nov 26, 2023

How urgent is this fix to get published? I have a few things in mind to also add, but may not have the time to do it all. Maybe wait a few more days before it gets out?

@nehzata nehzata deleted the dispose-closed-connection branch November 26, 2023 10:34
@nehzata
Copy link
Contributor Author

nehzata commented Nov 26, 2023

🙏 No trouble. I can hang a few days. Let me know if I can help in any way.

@isoos
Copy link
Owner

isoos commented Nov 27, 2023

Published in 3.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants