Re: Reapply graceful socket shutdown on Windows (revert 29992a6a509)

From: "Jelte Fennema-Nio" <postgres(at)jeltef(dot)nl>
To: "Michael Paquier" <michael(at)paquier(dot)xyz>
Cc: "Zsolt Parragi" <zsolt(dot)parragi(at)percona(dot)com>, "PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Andrey Borodin" <x4mmm(at)yandex-team(dot)ru>, "Thomas Munro" <thomas(dot)munro(at)gmail(dot)com>, "Nikolay Samokhvalov" <nik(at)postgres(dot)ai>, "Jacob Champion" <jacob(dot)champion(at)enterprisedb(dot)com>, "Gregory Burd" <greg(at)burd(dot)me>
Subject: Re: Reapply graceful socket shutdown on Windows (revert 29992a6a509)
Date: 2026-12-02 01:08:58
Message-ID: DN9UG82RMH5T.PYI24S4RWVMT@jeltef.nl
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 1 Dec 2026 at 08:26, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> That's a new thing.

Agreed, and to be clear I don't want to block this thread on the later
patches I'm proposing. 0001 is a serious improvement on its own already,
and it's a prerequisite for the later ones.

> Err, 0005, that controls with a GUC for how long a backend should stay
> around to flush its information, feels like an unstable knob to me.
> Let's assume that we do 0004, why would there be any need for 0005,
> then?

0001 fixes the case where a client is waiting for a response and then
gets a FATAL
0004 fixes the case where a client was idle and then wants to send
something but in the meantime got a FATAL
0005 fixes the case where a client is actively sending something and
during that send a FATAL happens. I added a test now to the patch
to show such a case: TLS handshake on a busy client where the
client cert is rejected by the server. Another example would be a
somewhat short COPY IN stream that the client keeps writing to
while a FATAL occurs.

The 0005 solution is indeed finicky, and I dislike it quite a lot. If
this is the only way to solve it, I'm not even sure if the solution is
worth it. But I don't really see another way. The Windows behaviour is
simply terrible: it's prone to these race conditions by design.

> Perhaps it would be better for Jacob to comment here. I was under
> the impression that there was little need for more than 0003 in terms
> of the tests, at least.

The (fairly simple) tests in 0004 fail consistently without the code
change in 0004.

Attachment Content-Type Size
v3-0001-Reapply-graceful-shutdown-changes-for-Windows.patch text/x-patch 2.4 KB
v3-0002-Revert-Skip-isolation-tests-that-terminate-other-.patch text/x-patch 6.4 KB
v3-0003-fixup-Reapply-graceful-shutdown-changes-for-Windo.patch text/x-patch 2.8 KB
v3-0004-libpq-On-Windows-read-pending-input-before-sendin.patch text/x-patch 8.6 KB
v3-0005-POC-Add-client_connection_linger_timeout-to-avoid.patch text/x-patch 15.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Melanie Plageman 2026-12-02 01:03:18 Re: Checkpointer write combining