Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x0xEh-004u4Q-0v for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Aug 2026 08:19:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x0xEf-00GSDr-03 for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Aug 2026 08:19:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x0xEe-00GSDi-2B for pgsql-hackers@lists.postgresql.org; Mon, 31 Aug 2026 08:19:20 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x0xEc-000000029wA-0NdK for pgsql-hackers@lists.postgresql.org; Mon, 31 Aug 2026 08:19:20 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49b8687630fso22329595e9.3 for ; Mon, 31 Aug 2026 01:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788164352; x=1788769152; darn=lists.postgresql.org; h=content-disposition:content-type:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TqmK5I6sJc0Vb/mWvrwALFJvfj3IuFWBSa2sbFU6e+w=; b=SMz6a63iabNQ5BLASrATGR/s3uiktr96xLvrYNxOe/AqKTr3wEU5L8wsx1jOUvbaVK Ju21H3bAMNvYXq3Exx+Vs+IGYFeyLXiSqzycvhwHEuCnhsnOBgk2viQ9u+y61N+qkJtG 5/RNqEwC6AjD80F/G8Wi8NXpgbeLBOB6Fs39RWZwpnvG3XypuzqLSNkpLDQ5e4JEAvl0 Z/iJbyj967VPaKBwJcYk5bVRa1zGqWiY8cNBxPxdOMq1onqQzpB9CStBpGzX42SYEH7y DD1IpvNnjEtQoIVsrInXpxsX2JDWEg/rG8iATpjR90Wx9nOblMIXleP8E9rKQIKMCYuW 9VPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788164352; x=1788769152; h=content-disposition:content-type:mime-version:message-id:subject:cc :to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TqmK5I6sJc0Vb/mWvrwALFJvfj3IuFWBSa2sbFU6e+w=; b=lHXkIPMR+d7gCTgCJnwDoMdmCvwOw/xV2uCaA1WdHDcl9ADPQEEbkJ4U9R6wgHmHxy sEP7k66HCZ2YMxVhyb/7xrcMlSuZQbPMkdgejxNoJme2fa5562B7u6NtX3sc75yqwSEx 0wqVTvJ1ldcgwNG/dfAjKUremKU2RIHGmPpe+ujPMlt4/jMg8DTdNdXfdXDUkN1Qmm4V 0P+gUvdA4/x7hGu+pkWjFwNZmzqSQpNj11eNJSreoX9qu3z2EvxB+hOJ4nTeDyoO6PAJ gwKwSJJexWzQ7CpFFs/QvtkvCy9vxmwf0yIL1vHAF14hFTNroFqBumtkZy83M8hwHP14 XvlA== X-Gm-Message-State: AFuF++kF7f0dLyoYch1l7ObA4AC/jy1FhvxqqdDSBgDNNQj4pei/IJRW U6VC2pdm2b4ujTliB9/AXDe168atuwfhES4o3Sx/Nt/aRVNghymUqCSWmaB8Iw== X-Gm-Gg: AR+sD11sMxWGSRD6Owg2j+gDwAX70lCorzGiXdloMMzaIGrNNGJ0kRycDXOeR1UTNLq gGxT/Owt/eXDL4ayMh6JOpxHQbr6kEw1c+zsqSoxk4yw73f7BLIXFcOdIIbTAyuNX3/C73xwYAy EDYb7Y7EXsP3ewRGIoNBg6c6ROUu7v1ie/IWMH48Rg/QfGuI34RuAFJA4S8gBfV3BjZVMpshNW9 duu0KFaxLAXU0QKE5kwgYaZmGfF4/S93zdWdmgSgDVskDx6b8Y9BVzi5FlV3TsAphkfs0+KNLNb D5QQhAdQ2ckVhQSwGllEVIJBfae86dgksQYdE5U00lTbx5J0rXwQXTo2Rdc+DWfKJ9qGx6nYO3l AxBEhMOvWmCqAj+VKny/h8ierCOTLKzvLjqOaeqrHIkEyA1lK5LeKg7TJ0IrFDSjVmAbFTPuDSh kQfzXV05NbEf8bvGoJ9+Z6EhyeN/DyWB/vRqczbahA/FvyLBsrESPQAdHmSqWLwSa6DBifxHjuJ g7LLq9Qpu/tQHFZmcRMNAtExtGGQZ9uAq/aReljQFXM3xKZ X-Received: by 2002:a05:600c:3549:b0:496:bffb:fb7b with SMTP id 5b1f17b1804b1-49b91c57464mr332739735e9.10.1788164351856; Mon, 31 Aug 2026 01:19:11 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49b91c9cf95sm207633115e9.1.2026.08.31.01.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 01:19:11 -0700 (PDT) Date: Mon, 31 Aug 2026 08:19:10 +0000 From: Bertrand Drouvot To: pgsql-hackers@lists.postgresql.org Cc: Michael Paquier Subject: pg_upgrade: Test --check with a running source server Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cPum+Eb+s0rOlekU" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --cPum+Eb+s0rOlekU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --cPum+Eb+s0rOlekU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-pg_upgrade-Test-check-with-a-running-source-serve.patch" From e21baac6d18d9d4803cc9a79170070e9c25ba65e Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Mon, 31 Aug 2026 03:03:33 +0000 Subject: [PATCH v1 1/2] pg_upgrade: Test --check with a running source server Commit 4fff78f009 added TAP coverage for pg_upgrade --check, but only after stopping the source server. Add 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. Also test 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. Author: Bertrand Drouvot Reviewed-by: Discussion: https://postgr.es/m/... --- src/bin/pg_upgrade/t/002_pg_upgrade.pl | 45 ++++++++++++++++++++--- src/bin/pg_upgrade/t/003_logical_slots.pl | 13 +++++++ 2 files changed, 53 insertions(+), 5 deletions(-) 100.0% src/bin/pg_upgrade/t/ diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl index 0a4121fdc4d..9b904a8d1ea 100644 --- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl +++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl @@ -475,6 +475,46 @@ if (defined($ENV{oldinstall})) } } +# In a VPATH build, we'll be started in the source directory, but we want +# to run pg_upgrade in the build directory so that any files generated finish +# in it, like delete_old_cluster.{sh,bat}. +chdir ${PostgreSQL::Test::Utils::tmp_check}; + +my @live_check_command = ( + 'pg_upgrade', '--no-sync', + '--old-datadir' => $oldnode->data_dir, + '--new-datadir' => $newnode->data_dir, + '--old-bindir' => $oldbindir, + '--new-bindir' => $newbindir, + '--socketdir' => $newnode->host, + '--old-port' => $oldnode->port); + +# A live check must use different ports for the running old server and +# the temporary new server. +command_checks_all( + [ + @live_check_command, + '--new-port' => $oldnode->port, + $mode, '--check', + ], + 1, + [ + qr/When checking a live server, the old and new port numbers must be different\./ + ], + [], + 'pg_upgrade --check with the same old and new ports'); + +rmtree($newnode->data_dir . "/pg_upgrade_output.d"); + +# Check the old cluster while it is running. +command_ok( + [ + @live_check_command, + '--new-port' => $newnode->port, + $mode, '--check', + ], + 'run of pg_upgrade --check with old instance running'); + # Create an invalid database, will be deleted below $oldnode->safe_psql( 'postgres', qq( @@ -482,11 +522,6 @@ $oldnode->safe_psql( UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'; )); -# In a VPATH build, we'll be started in the source directory, but we want -# to run pg_upgrade in the build directory so that any files generated finish -# in it, like delete_old_cluster.{sh,bat}. -chdir ${PostgreSQL::Test::Utils::tmp_check}; - # Upgrade the instance. $oldnode->stop; diff --git a/src/bin/pg_upgrade/t/003_logical_slots.pl b/src/bin/pg_upgrade/t/003_logical_slots.pl index 01ab82402ae..b0ebf845747 100644 --- a/src/bin/pg_upgrade/t/003_logical_slots.pl +++ b/src/bin/pg_upgrade/t/003_logical_slots.pl @@ -158,6 +158,19 @@ $oldpub->safe_psql( SELECT count(*) FROM pg_logical_emit_message('false', 'prefix', 'This is a non-transactional message', true); SELECT pg_replication_slot_advance('test_slot3', pg_current_wal_lsn()); ]); + +# Sleep here because Windows builds cannot check postmaster.pid exactly, +# so they may mistake a pre-existing postmaster.pid for one created by the +# postmaster they start. Waiting more than the 2 seconds slop time allowed +# by wait_for_postmaster_start() prevents that mistake. +sleep 3 if ($windows_os); + +# A live check cannot require slots to have consumed all WAL because the old +# server can generate more WAL concurrently. Verify that these slots are accepted +# now. The check below verifies rejection after shutdown. +command_ok([ @pg_upgrade_cmd, '--check' ], + 'pg_upgrade --check with live old cluster and unconsumed WAL'); + $oldpub->stop; # pg_upgrade will fail because there are slots still having unconsumed WAL -- 2.34.1 --cPum+Eb+s0rOlekU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0002-Fix-outdated-function-name-in-001_start_stop.pl.patch" From 6482720e5d5e7a8d45435b51917e2864b0afa871 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Mon, 31 Aug 2026 07:54:08 +0000 Subject: [PATCH v1 2/2] Fix outdated function name in 001_start_stop.pl Commit a745b936507 renamed wait_for_postmaster() to wait_for_postmaster_start(), but missed this reference in 001_start_stop.pl. Update the comment. Author: Bertrand Drouvot Reviewed-by: Discussion: https://postgr.es/m/... --- src/bin/pg_ctl/t/001_start_stop.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 100.0% src/bin/pg_ctl/t/ diff --git a/src/bin/pg_ctl/t/001_start_stop.pl b/src/bin/pg_ctl/t/001_start_stop.pl index a189b379f55..38634fd26ce 100644 --- a/src/bin/pg_ctl/t/001_start_stop.pl +++ b/src/bin/pg_ctl/t/001_start_stop.pl @@ -55,7 +55,7 @@ command_like($ctlcmd, qr/done.*server started/s, 'pg_ctl start'); # sleep here is because Windows builds can't check postmaster.pid exactly, # so they may mistake a pre-existing postmaster.pid for one created by the # postmaster they start. Waiting more than the 2 seconds slop time allowed -# by wait_for_postmaster() prevents that mistake. +# by wait_for_postmaster_start() prevents that mistake. sleep 3 if ($windows_os); command_fails([ 'pg_ctl', 'start', '--pgdata' => "$tempdir/data" ], 'second pg_ctl start fails'); -- 2.34.1 --cPum+Eb+s0rOlekU--