Re: Refactoring postmaster's code to cleanup after child exit

From: Michael Banck <mbanck(at)gmx(dot)net>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Refactoring postmaster's code to cleanup after child exit
Date: 2026-07-07 08:39:56
Message-ID: 20260707083956.GB15075@p46.dedyn.io;lightning.p46.dedyn.io
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Feb 16, 2026 at 02:05:01PM +0100, Michael Banck wrote:
> On Mon, Feb 16, 2026 at 09:51:00AM +0200, Heikki Linnakangas wrote:
> > On 15/02/2026 10:11, Michael Banck wrote:
> > > On Tue, Oct 08, 2024 at 12:55:00AM +0300, Heikki Linnakangas wrote:
> > > > In the meanwhile, here is a one more version of the test patches, with a
> > > > SKIP that checks that IO::Socket::UNIX works.
> > >
> > > I've only realized recently, but those postmaster tap tests have been
> > > failing during Debian package build (see e.g. [0]) on hurd-i386/amd64 with
> > >
> > > |send: Cannot determine peer address at t/002_connection_limits.pl line 136.
> > >
> > > This wasn't widely noticed because both architectures are on the (not
> > > small) list of arches where test suite failures are ignored[1] but I
> > > think nowadays it is the only (or one of the very few) remaining
> > > issue(s). I encountered it now when I tried to turn on
> > > --enable-tap-tests on fruitcrow.
> > >
> > > The Perl code run through strace shows it runs connect(), then
> > > getpeername() and then sendto(), as seen here[2]. However, getpeername()
> > > on Unix sockets is not implemented on the Hurd yet[3] (granted, FSVO
> > > "yet", the issue is 20 years old). I've opened an issue in Perl asking
> > > to work around this here: https://github.com/Perl/perl5/issues/24195
> > >
> > > Would something like the attached be acceptable in the interim to have
> > > this test be skipped on the Hurd as well?

We've installed this in the Debian package a while ago[1], and this
seems to have worked so far as the postmaster tests no longer lead to
failure:

|make[2]: Leaving directory
|'/build/reproducible-path/postgresql-18-18.4/build/src/test/perl'
|make -C postmaster check
|make[2]: Entering directory
|'/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster'
|echo "# +++ tap check in src/test/postmaster +++" && rm -rf
|'/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster'/tmp_check
|&& /bin/mkdir -p
|'/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster'/tmp_check
|&& cd
|/build/reproducible-path/postgresql-18-18.4/build/../src/test/postmaster
|&&
|TESTLOGDIR='/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster/tmp_check/log'
|TESTDATADIR='/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster/tmp_check'
|PATH="/build/reproducible-path/postgresql-18-18.4/build/tmp_install/usr/lib/postgresql/18/bin:/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster:$PATH"
|LD_LIBRARY_PATH="/build/reproducible-path/postgresql-18-18.4/build/tmp_install/usr/lib/x86_64-gnu:$LD_LIBRARY_PATH"
|INITDB_TEMPLATE='/build/reproducible-path/postgresql-18-18.4/build'/tmp_install/initdb-template
|PGPORT='65432'
|top_builddir='/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster/../../..'
|PG_REGRESS='/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster/../../../src/test/regress/pg_regress'
|share_contrib_dir='/build/reproducible-path/postgresql-18-18.4/build/tmp_install/usr/share/postgresql/18/'
|/usr/bin/prove -I
|/build/reproducible-path/postgresql-18-18.4/build/../src/test/perl/ -I
|/build/reproducible-path/postgresql-18-18.4/build/../src/test/postmaster
|--verbose t/*.pl
|# +++ tap check in src/test/postmaster +++
|t/001_basic.pl ..............
|ok 1 - postgres --help exit code 0
|ok 2 - postgres --help goes to stdout
|ok 3 - postgres --help nothing to stderr
|ok 4 - postgres --help maximum line length
|ok 5 - postgres --version exit code 0
|ok 6 - postgres --version goes to stdout
|ok 7 - postgres --version nothing to stderr
|ok 8 - postgres with invalid option nonzero exit code
|ok 9 - postgres with invalid option prints error message
|1..9
|ok
|# IO::Socket::UNIX does not work: send: Cannot determine peer address at
|# /build/reproducible-path/postgresql-18-18.4/build/../src/test/perl/PostgreSQL/Test/Cluster.pm
|# line 356.
|t/002_connection_limits.pl ..
|# initializing database system by copying initdb template
|# connect output:
|# {
|# 'stderr' => 'background_psql: ready
|# ',
|# 'stdout' => 'background_psql: ready
|# '
|# }
|# connect output:
|# {
|# 'stderr' => 'background_psql: ready
|# ',
|# 'stdout' => 'background_psql: ready
|# '
|# }
|# connect output:
|# {
|# 'stderr' => 'background_psql: ready
|# ',
|# 'stdout' => 'background_psql: ready
|# '
|# }
|ok 1 - regular connections limit
|ok 2 - regular connections limit: matches
|ok 3 - regular connections limit: client backend process exited
|# connect output:
|# {
|# 'stderr' => 'background_psql: ready
|# ',
|# 'stdout' => 'background_psql: ready
|# '
|# }
|# connect output:
|# {
|# 'stderr' => 'background_psql: ready
|# ',
|# 'stdout' => 'background_psql: ready
|# '
|# }
|ok 4 - reserved_connections limit
|ok 5 - reserved_connections limit: matches
|ok 6 - reserved_connections limit: client backend process exited
|# connect output:
|# {
|# 'stderr' => 'background_psql: ready
|# ',
|# 'stdout' => 'background_psql: ready
|# '
|# }
|ok 7 - superuser_reserved_connections limit
|ok 8 - superuser_reserved_connections limit: matches
|ok 9 - superuser_reserved_connections limit: client backend process
|exited
|ok 10 # skip this test requires working raw_connect()
|1..10
|ok
|# IO::Socket::UNIX does not work: send: Cannot determine peer address at
|# /build/reproducible-path/postgresql-18-18.4/build/../src/test/perl/PostgreSQL/Test/Cluster.pm
|# line 356.
|t/003_start_stop.pl ......... skipped: this test requires working
|raw_connect()
|# IO::Socket::UNIX does not work: send: Cannot determine peer address at
|# /build/reproducible-path/postgresql-18-18.4/build/../src/test/perl/PostgreSQL/Test/Cluster.pm
|# line 356.
|t/004_negotiate.pl .......... skipped: this test requires working
|raw_connect()
|All tests successful.
|Files=4, Tests=19, 9 wallclock secs ( 0.02 usr + 0.01 sys = 0.03 CPU)
|Result: PASS
|make[2]: Leaving directory
|'/build/reproducible-path/postgresql-18-18.4/build/src/test/postmaster'

It does seem to skip over the other postmaster TAP tests as well though
(t/003_start_stop.pl and t/004_negotiate.pl), is that expected?

> > It would be nice to silence that failure one way or another. If we go with
> > this approach, would need a comment at least to explain it.
>
> Right.
>
> > It seems a little awkward to send garbage to the server for this. Could we
> > replace the send() with a non-blocking recv() or something?
>
> I am not quite sure how this would look like?

Do you have some suggestion here? I am still not sure what exactly you
mean.

Cheers,

Michael

[1] https://salsa.debian.org/postgresql/postgresql/-/blob/18/debian/patches/hurd-postmaster-socket-send?ref_type=heads

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nitin Motiani 2026-07-07 08:52:25 Re: [PATCH] Fix for bug #19474: LIKE fails to match literal backslashes with nondeterministic collations
Previous Message Xuneng Zhou 2026-07-07 08:27:56 Re: BUG: ReadStream look-ahead exhausts local buffers when effective_io_concurrency>=64