From 248eda6d18ddf88e9c7da07ac79217fd579e1d7e Mon Sep 17 00:00:00 2001
From: Jelte Fennema <jelte.fennema@microsoft.com>
Date: Thu, 30 Sep 2021 11:46:21 +0200
Subject: [PATCH] Consider ETIMEDOUT a connection failure

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.
---
 src/include/port.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/include/port.h b/src/include/port.h
index 82f63de325..970d1993ec 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -115,6 +115,7 @@ extern void pgfnames_cleanup(char **filenames);
 	EPIPE: \
 	case ECONNRESET: \
 	case ECONNABORTED: \
+	case ETIMEDOUT: \
 	case EHOSTDOWN: \
 	case EHOSTUNREACH: \
 	case ENETDOWN: \
-- 
2.17.1

