Closed FlixCoder closed 1 year ago
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.
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.
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.
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.
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.