I have a web service in Gin that calls Postgresql running on AWS RDS with multi-az failover. When I reboot with failover the primary database and failover starts calls to the web service hang without even getting to the event handler. Once the failover is complete calls to the web service fail due to not being able to find the Postgresql table. If I restart the web service then calls to the web service succeed.
I've done this with both sql/db and the
github.com/jackc/pgx/v5/pgxpool connection pool. I hoped the pgxpool would be resilient enough to reconnect once multi-az failover had completed, but this isn't happening.
I could implement retry logic which would probably require a new connection, but the calls that hang don't even get to the event handler.
Is there a pattern for supporting continuing connection or reconnect to Postgresql when failover happens? Are there drivers or packages that implement this?