From: Tom Lane <tgl@sss.pgh.pa.us>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Fujii Masao <fujii@postgresql.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: postgres_fdw: reestablish new connection if cached one is detect
Date: Thu, 08 Oct 2020 09:47:20 -0400
Message-ID: <2461600.1602164840@sss.pgh.pa.us> (raw)
In-Reply-To: <eeec0120-9ca1-bd20-a00b-5fc5f2c862a1@oss.nttdata.com>
References: <E1kPc9v-0005L4-2l@gemulon.postgresql.org>
<20201007021347.GD2256@paquier.xyz>
<14cd32c8-9532-47b8-77d4-b81eb3b192ea@oss.nttdata.com>
<fb96a78e-54ad-832f-b2be-d589abdfd7df@oss.nttdata.com>
<78d509fe-f87a-7046-672a-f86cb6f6957d@oss.nttdata.com>
<eeec0120-9ca1-bd20-a00b-5fc5f2c862a1@oss.nttdata.com>
Fujii Masao <masao.fujii@oss.nttdata.com> writes:
>> Therefore, the easy fix is to make libpq mark the connection as
>> CONNECTION_BAD even in ECONNABORTED, like we do in ECONNRESET.
> Patch attached. This patch also changes errcode_for_socket_access()
> so that it uses ERRCODE_CONNECTION_FAILURE rather than
> ERRCODE_INTERNAL_ERROR as sqlerrorcode in ECONNABORTED case
> like ECONNRESET. Is this sane?
Some digging around on the net suggests that Windows will only return
WSAECONNRESET for the case where it gets a TCP RST packet from the remote
host. Other cases of TCP connection loss (e.g. timeout) are reported
as WSAECONNABORTED.
I think that our code generally only expects ECONNRESET to be reported
for a lost connection. Based on this info, we clearly need to handle
ECONNABORTED as being equivalent to that. I don't see any reason why
we'd care to distinguish the two cases.
So it seems like (a) we'd better make sure that ECONNABORTED is
recognized anyplace that we're testing for ECONNRESET, and (b) that
seems like a back-patchable bug fix, independently of the immediate
issue.
On the other hand, it seems a bit odd that we've not recognized
this issue long since. Maybe the preference for ECONNABORTED only
exists on a few Windows versions?
I've not checked your patch in detail.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us, masao.fujii@oss.nttdata.com, michael@paquier.xyz, fujii@postgresql.org
Subject: Re: pgsql: postgres_fdw: reestablish new connection if cached one is detect
In-Reply-To: <2461600.1602164840@sss.pgh.pa.us>
References: <E1kPc9v-0005L4-2l@gemulon.postgresql.org> <20201007021347.GD2256@paquier.xyz> <14cd32c8-9532-47b8-77d4-b81eb3b192ea@oss.nttdata.com> <fb96a78e-54ad-832f-b2be-d589abdfd7df@oss.nttdata.com> <78d509fe-f87a-7046-672a-f86cb6f6957d@oss.nttdata.com> <eeec0120-9ca1-bd20-a00b-5fc5f2c862a1@oss.nttdata.com> <2461600.1602164840@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox