From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Re-enable SSL connect_fails tests, and fix related race conditio
Date: Tue, 22 Apr 2025 19:10:55 +0000
Message-ID: <E1u7J1D-001I4C-1H@gemulon.postgresql.org> (raw)
Re-enable SSL connect_fails tests, and fix related race conditions.
Cluster.pm's connect_fails routine has long had the ability to
sniff the postmaster log file for expected messages after a
connection failure. However, that's always had a race condition:
on some platforms it's possible for psql to exit and the test
script to slurp up the postmaster log before the backend process
has been able to write out its final log messages. Back in
commit 55828a6b6 we disabled a bunch of tests after discovering
that, and the aim of this patch is to re-enable them.
(The sibling function connect_ok doesn't seem to have a similar
problem, mainly because the messages we look for come out during
the authentication handshake, so that if psql reports successful
connection they should certainly have been emitted already.)
The solution used here is borrowed from 002_connection_limits.pl's
connect_fails_wait routine: set the server's log_min_messages setting
to DEBUG2 so that the postmaster will log child-process exit, and then
wait till we see that log entry before checking for the messages we
are actually interested in.
If a TAP test uses connect_fails' log_like or log_unlike options, and
forgets to set log_min_messages, those connect_fails calls will now
hang until timeout. Fixing up the existing callers shows that we had
several other TAP tests that were in theory vulnerable to the same
problem. It's unclear whether the lack of failures is just luck, or
lack of buildfarm coverage, or perhaps there is some obscure timing
effect that only manifests in SSL connections. In any case, this
change should in principle make those other call sites more robust.
I'm not inclined to back-patch though, unless sometime we observe
an actual failure in one of them.
Reported-by: Andrew Dunstan <andrew@dunslane.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/984fca80-85a8-4c6f-a5cc-bb860950b435@dunslane.net
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/e0f373ee42a40a41bdfc025a1641d351580991c4
Modified Files
--------------
src/test/authentication/t/001_password.pl | 2 +
src/test/authentication/t/003_peer.pl | 2 +
src/test/kerberos/t/001_auth.pl | 1 +
src/test/ldap/t/001_auth.pl | 2 +
src/test/modules/oauth_validator/t/001_server.pl | 2 +
src/test/perl/PostgreSQL/Test/Cluster.pm | 19 +++++--
src/test/ssl/t/001_ssltests.pl | 67 ++++++++++--------------
7 files changed, 53 insertions(+), 42 deletions(-)
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Re-enable SSL connect_fails tests, and fix related race conditio
In-Reply-To: <E1u7J1D-001I4C-1H@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