Subject: pg_upgrade: Test --check with a running source server

From: Bertrand Drouvot <[email-masked]>
Date: Mon, 31 Aug 2026 08:19:10 +0000

Hi hackers,

While doing some tests for [0], I noticed that we don't have coverage for
pg_upgrade --check with a running source server.

Indeed, commit 4fff78f009 added TAP coverage for pg_upgrade --check, but only
after stopping the source server.

0001 attached adds coverage with the source still running. This covers live server
detection, connection details from postmaster.pid, control data from pg_controldata,
reuse of the running postmaster, and the requirement for different source and target
ports.

It also tests that logical slots with unconsumed WAL are accepted during a live
check. The existing offline check verifies that the same slots are rejected after
shutdown.

Remarks:

1/ my CI was failing on Windows (at the new 003_logical_slots.pl test) for the
same reason why a sleep is part of 001_start_stop.pl. So adding the same comment
and sleep in 003_logical_slots.pl too.

2/ while at 1/ I observed the comment in 001_start_stop.pl was using a stale
function name. 0002 fixes it.

3/ the proposed tests would have had catch === 2 mentioned in [0].

[0]: https://postgr.es/m/apUL3N4IE934qJ08%40bdtpg

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

---

From: Ewan Young <[email-masked]>
Date: Mon, 31 Aug 2026 18:54:52 +0800

> 3/ the proposed tests would have had catch === 2 mentioned in [0].

Thanks for the patches. I had a look at both patches.

One optional thought on the success case in 002: command_like()
matching the live-mode banner would be a bit more precise than
command_ok(), since exit code 0 alone can't tell a live check from an
offline one (against a stopped old server, pg_upgrade would start it
itself and succeed just the same):

    command_like(..., qr/Performing Consistency Checks on Old Live Server/, ...)

0002 looks good: a745b936507 did rename wait_for_postmaster() to
wait_for_postmaster_start(), and it shows the line you're fixing
is the only stale reference left in the tree.

-- 
Regards,
Ewan Young

---

From: Bertrand Drouvot <[email-masked]>
Date: Mon, 31 Aug 2026 11:27:07 +0000

Hi,

> Thanks for the patches. I had a look at both patches.

Thanks!

>     command_like(..., qr/Performing Consistency Checks on Old Live Server/, ...)

The preceding test already proves that live mode is selected by checking that
using the same port error, which is specific to live checks. That said, matching
the banner makes it self contained, so changed it that way in the attached v2.

Regards,

---

From: Ewan Young <[email-masked]>
Date: Tue, 1 Sep 2026 16:20:57 +0800

> the banner makes it self contained, so changed it that way in the attached v2.

Fair point -- and thanks for the new version (and the credit).

v2 looks good to me.  Re-tested both patches on top of current master:
the pg_upgrade and pg_ctl TAP suites pass, including the no-stderr
check that command_like() adds.  Nothing more from me.

-- 
Regards,
Ewan Young