1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Recognize network-failure errnos as indicating hard connection loss.

Up to now, only ECONNRESET (and EPIPE, in most but not quite all places)
received special treatment in our error handling logic.  This patch
changes things so that related error codes such as ECONNABORTED are
also recognized as indicating that the connection's dead and unlikely
to come back.

We continue to think, however, that only ECONNRESET and EPIPE should be
reported as probable server crashes; the other cases indicate network
connectivity problems but prove little about the server's state.  Thus,
there's no change in the error message texts that are output for such
cases.  The key practical effect is that errcode_for_socket_access()
will report ERRCODE_CONNECTION_FAILURE rather than
ERRCODE_INTERNAL_ERROR for a network failure.  It's expected that this
will fix buildfarm member lorikeet's failures since commit 32a9c0bdf,
as that seems to be due to not treating ECONNABORTED equivalently to
ECONNRESET.

The set of errnos treated this way now includes ECONNABORTED, EHOSTDOWN,
EHOSTUNREACH, ENETDOWN, ENETRESET, and ENETUNREACH.  Several of these
were second-class citizens in terms of their handling in places like
get_errno_symbol(), so upgrade the infrastructure where necessary.

As committed, this patch assumes that all these symbols are defined
everywhere.  POSIX specifies all of them except EHOSTDOWN, but that
seems to exist on all platforms of interest; we'll see what the
buildfarm says about that.

Probably this should be back-patched, but let's see what the buildfarm
thinks of it first.

Fujii Masao and Tom Lane

Discussion: https://postgr.es/m/2621622.1602184554@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2020-10-10 13:28:12 -04:00
parent ed30b1a60d
commit fe27009cbb
9 changed files with 98 additions and 60 deletions

View File

@ -146,16 +146,12 @@ get_errno_symbol(int errnum)
return "EBUSY";
case ECHILD:
return "ECHILD";
#ifdef ECONNABORTED
case ECONNABORTED:
return "ECONNABORTED";
#endif
case ECONNREFUSED:
return "ECONNREFUSED";
#ifdef ECONNRESET
case ECONNRESET:
return "ECONNRESET";
#endif
case EDEADLK:
return "EDEADLK";
case EDOM:
@ -166,10 +162,10 @@ get_errno_symbol(int errnum)
return "EFAULT";
case EFBIG:
return "EFBIG";
#ifdef EHOSTUNREACH
case EHOSTDOWN:
return "EHOSTDOWN";
case EHOSTUNREACH:
return "EHOSTUNREACH";
#endif
case EIDRM:
return "EIDRM";
case EINPROGRESS:
@ -198,6 +194,12 @@ get_errno_symbol(int errnum)
return "EMSGSIZE";
case ENAMETOOLONG:
return "ENAMETOOLONG";
case ENETDOWN:
return "ENETDOWN";
case ENETRESET:
return "ENETRESET";
case ENETUNREACH:
return "ENETUNREACH";
case ENFILE:
return "ENFILE";
case ENOBUFS: