Description
Setup
I am using a serverless setup on GCP Cloud Run (knative) with a database in VPC accessed via a serverless connector.
This is a similar to a setup where a server communicates with a database behind an HAProxy or an NGINX.
The only difference is that if the server is not receiving requests, its CPU is heavily throttled.
Problem
I started receiving errors like:
write tcp 169.254.8.1:33834->10.1.0.2:14157: write: connection reset by peer
Where 10.1.0.2
is the database, that tells me that most likely the connection to the proxy was maintained but the connection to the host was killed. I would expect pq
to be able to detect that, kill the connection and retry on a new one. But it seems it is not the case and the pool will happily continue using the connection even if it is effectively dead.
This is patchable with a SetConnMaxIdleTime
or SetConnMaxLifetime
, but I feel a network error like that should be able to detected and acted upon directly.