Previously successfully opened TCP connections can still fail on reads with ETIMEDOUT. This should be considered a connection failure, so that the connection in libpq is marked as CONNECTION_BAD. The reason I got an ETIMEDOUT was, because I had set a low tcp_user_timeout in the connection string. However, it can probably also happen due to keepalive limits being reached.
0001-Consider-ETIMEDOUT-a-connection-failure.patch
Description: 0001-Consider-ETIMEDOUT-a-connection-failure.patch