pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Move libpq's write_failed mechanism down to pqsecure_raw_write()
Date: Sat, 12 Feb 2022 19:00:20 +0000
Message-ID: <E1nIxd6-0007XV-84@gemulon.postgresql.org> (raw)

Move libpq's write_failed mechanism down to pqsecure_raw_write().

Commit 1f39a1c06 implemented write-failure postponement in pqSendSome,
which is above SSL/GSS processing.  However, we've now seen failures
indicating that (some versions of?) OpenSSL have a tendency to report
write failures prematurely too.  Hence, move the primary responsibility
for postponing write failures down to pqsecure_raw_write(), below
SSL/GSS processing.  pqSendSome now sets write_failed only in corner
cases where we'd lost the connection already.

A side-effect of this change is that errors detected in the SSL/GSS
layer itself will be reported immediately (as if they were read
errors) rather than being postponed like write errors.  That's
reverting an effect of 1f39a1c06, and I think it's fine: if there's
not a socket-level error, it's hard to be sure whether an OpenSSL
error ought to be considered a read or write failure anyway.

Another important point is that write-failure postponement is now
effective during connection setup.  OpenSSL's misbehavior of this
sort occurs during SSL_connect(), so that's a change we want.

Per bug #17391 from Nazir Bilal Yavuz.  Possibly this should be
back-patched, but I think it prudent to let it age awhile in HEAD
first.

Discussion: https://postgr.es/m/17391-304f81bcf724b58b@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/faa189c932d51945b2285e277128b0f26b96afdd

Modified Files
--------------
src/interfaces/libpq/fe-misc.c   | 47 ++++++++++-------------
src/interfaces/libpq/fe-secure.c | 81 ++++++++++++++++++++++++++++++++++------
2 files changed, 90 insertions(+), 38 deletions(-)



Message-ID: <E1nIxd6-0007XV-84@gemulon.postgresql.org>
Permalink:  ../E1nIxd6-0007XV-84@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nIxd6-0007XV-84@gemulon.postgresql.org

 · 

reply

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
  Subject: Re: pgsql: Move libpq's write_failed mechanism down to pqsecure_raw_write()
  In-Reply-To: <E1nIxd6-0007XV-84@gemulon.postgresql.org>
  References: <E1nIxd6-0007XV-84@gemulon.postgresql.org>

* 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