soniq
soniq copied to clipboard
Database Reconnect
When Aiven is switching the Database due to automatic maintenance one seems not to be able to reconnect properly.
Also, the server does not crash, which would trigger a restart and thus a reconnect.
Currently it just loses the database-connection and gets unresponsive.
I’ll look into that. Meanwhile:
A pg.Pool will handle this for you, even if you never want more than one client.
https://github.com/brianc/node-postgres/issues/1558
Okey, just another hint for that.
In the logs I can see some errors like this:
Error: connect ETIMEDOUT xx.xxx.xx.xxx:12345
However, Aiven is changing the IP-Address with that maintenance:
NOTE: The DNS name of the service will remain the same while maintenance is being performed, but the underlying IP address will change.
Maybe pg.Pool is not trying to connect to the DNS-Name once resolved and keeps trying to connect to the IP-Address resolved at some point before.
@dustin-H what should be the expected behavior? Trying to reconnect or exit the entire app? Since the state after a lost connection is “undefined”, I would prefer to just exit the entire program (and restart).
Yes, I'd also prefer just stopping the process.
We need to check, whether this is still a problem when using Typeorm or whether they can handle it.
This is still the case with Typeorm.