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

Clean function does not handle "idle in transaction" and "idle in transaction (aborted)" connections states #89

Open
iOrcohen opened this issue Jul 13, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@iOrcohen
Copy link

iOrcohen commented Jul 13, 2023

Currently, the clean function in our application does not properly handle connections in the "idle in transaction" and "idle in transaction (aborted)" states, leading to potential issues and resource leaks. This problem occurs when connections are left open but not actively executing any queries, resulting in a waste of system resources and potential conflicts.

To address this problem, we need to update the clean function to properly handle these connection states. The function should be able to identify and close connections that are stuck in either "idle in transaction" or "idle in transaction (aborted)" states, ensuring that our application maintains a healthy and efficient connection pool.

We are solving this issue right now by creating a patch for the NPM with the following changes in the code -

in 3 occurrences in src/index.js -

AND state = 'idle'

Changed to -

AND state in ('idle', 'idle in transaction', 'idle in transaction (aborted)', 'disabled')
@MatteoGioioso MatteoGioioso self-assigned this Jul 14, 2023
@MatteoGioioso MatteoGioioso added the enhancement New feature or request label Jul 14, 2023
@MatteoGioioso
Copy link
Owner

Thanks for reporting this issue. I think we could do this, but I would prefer pass it as an option.

@iOrcohen
Copy link
Author

Thanks for the quick answer !
I would be love to open a PR if you like, with the option to enable this.

@MatteoGioioso
Copy link
Owner

Sure, a PR would be highly appreciated 🙏

Could you please explain how would you like to approach this?
I was thinking to pass an array additionalConnectionsState: ['idle in transaction', 'idle in transaction (aborted)', 'disabled'], but feel free to suggest whatever works best.

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

No branches or pull requests

2 participants