Hi!

I have a little, low-traffic web app which connects to postgres 10 using 
the pgx library (https://pkg.go.dev/github.com/jackc/pgx), and the database 
connection gets closed causing 500 server error to be returned. I'm pretty 
sure this is related to the db server being rebooted after updates and 
restarting the application fixes the problem.

I found the blog post below about how to process reconnects, and I was 
wondering how other people handle the db auto-reconnect scenario.

Synopsis: The author attaches functions to the db.Conn variable, and one of 
the functions has logic to check if the connection is valid then reconnect 
if the connection is invalid.

https://blog.marahin.pl/golang-postgres-auto-reconnect-4b5e5cc09a39

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5a0268b2-83ba-4bdb-bf38-2ea981f2337cn%40googlegroups.com.

Reply via email to