Re: Refactoring postmaster's code to cleanup after child exit
Michael Banck <mbanck@gmx.net>
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
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix test name and username used in failed connection attempts
- 2a943afcff44 18.0 landed
-
tests: Don't fail due to high default timeout in postmaster/003_start_stop
- b48832cddbf5 18.0 landed
-
tests: Fix race condition in postmaster/002_connection_limits
- 71d1ed6fe129 18.0 landed
-
Pass MyPMChildSlot as an explicit argument to child process
- 5b007868577a 18.0 landed
-
Assign a child slot to every postmaster child process
- a78af0427015 18.0 landed
-
Kill dead-end children when there's nothing else left
- bb861414fea3 18.0 landed
-
Replace postmaster.c's own backend type codes with BackendType
- 18d67a8d7d30 18.0 landed
-
Use an shmem_exit callback to remove backend from PMChildFlags on exit
- 2bbc261ddbdf 18.0 landed
-
Add test for dead-end backends
- 85ec945b7880 18.0 landed
-
Add test for connection limits
- 6a1d0d470e84 18.0 landed
-
Fix garbled process name on backend crash
- 56d23855c864 18.0 landed
-
Consolidate postmaster code to launch background processes
- 3354f85284dc 18.0 landed
-
Fix comment on processes being kept over a restart
- a79ed10e6c6b 18.0 landed
-
Refactor code to handle death of a backend or bgworker in postmaster
- 28a520c0b773 18.0 landed
-
Make BackgroundWorkerList doubly-linked
- b43100fa71d7 18.0 landed
-
Minor refactoring of assign_backendlist_entry()
- 63bef4df975c 18.0 landed
-
Fix outdated comment; all running bgworkers are in BackendList
- ef4c35b4166e 18.0 landed
-
Allow building with MSVC and Strawberry perl
- 341f4e002d46 16.0 cited
-
Fix rare failure in LDAP tests.
- f44b9b625bed 14.0 cited
-
Allow notifications to bgworkers without database connections.
- 8a02b3d732cf 9.6.0 cited