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

Pool building freezes when connections drop during initial setup #142

Closed
FlixCoder opened this issue Apr 24, 2023 · 4 comments
Closed

Pool building freezes when connections drop during initial setup #142

FlixCoder opened this issue Apr 24, 2023 · 4 comments

Comments

@FlixCoder
Copy link

Hi!

I am using r2d2 0.8.10 and noticed, that my service gets stuck on startup consistently under certain conditions: When the database becomes available, while r2d2 is already trying to connect.

The problem is, that in the initial startup phase, all connections are reset until postgresql is then fully start up.

During the build of the pool, the builder waits until the specified amount of connections is reached. However, it only starts connecting the specified amount of connections, so if one of those is dropped during the waiting time, the builder infinitely waits.

I hope this was understandable and thank you!

PS:
As a workaround, it seems to work to lower the connection_timeout, it somehow makes it way less likely to appear.

@sfackler
Copy link
Owner

The pool will retry after failed connection attemps: https://github.com/sfackler/r2d2/blob/master/src/lib.rs#L272-L278.

Lowering the connection timeout will increase the rate at which those retries will be made.

@FlixCoder
Copy link
Author

Ah I see, then the freeze might stem from another reason, but it certainly freezes. It normally logs reconnection attempts, but there is no output for like 5 minutes, even though the connection timeout is 30 seconds.
With 5 seconds it somehow errors, maybe the condition is just more difficult to occur.

@sfackler
Copy link
Owner

I don't think I can see how it's possible for initialization to take longer than the connection timeout. A self contained example of your issue would be helpful.

@FlixCoder
Copy link
Author

Hmm, I am not able to reproduce it in the setup I expected it to happen. It seems to maybe not be related to the pool start up even, so it might be a diesel or my own issue, so closing this for now! Thank you for the quick response and sorry for any inconvenience.

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

No branches or pull requests

2 participants