002_pg_upgrade is broken for custom install
Hi All,
When oldinstall and olddump environment variables are set,
002_pg_upgrade.pl test does not finish and fails.
# initializing database system by running initdb
ok 1 - check locales in original cluster
ok 2 - loaded old dump file
# initializing database system by running initdb
ok 3 # skip source node not using default install
ok 4 - dump before running pg_upgrade
# test failed
stderr:
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 29 just after 4.
Doesn't look like it's expected.
Even if I rollback the history as far as
f52345995d3691de7b0a888903b6cfed1497c672, the failure still appears.
IIRC, the test was working fine till October 2024. But I might be
wrong. Don't have energy to try git blame right now, but might do once
I get some time.
--
Best Wishes,
Ashutosh Bapat
On 2025-Apr-04, Ashutosh Bapat wrote:
# test failed
stderr:
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 29 just after 4.Doesn't look like it's expected.
Nope. Please have a look at the tmp_check/log/regress_002* log file --
that might contain a better indication of what the problem is.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
On Fri, Apr 4, 2025 at 5:02 PM Álvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2025-Apr-04, Ashutosh Bapat wrote:
# test failed
stderr:
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 29 just after 4.Doesn't look like it's expected.
Nope. Please have a look at the tmp_check/log/regress_002* log file --
that might contain a better indication of what the problem is.
Not much there
[17:08:28.162](0.939s) ok 3 # skip source node not using default install
# Running: pg_dumpall --no-sync --dbname port=13779
host=/tmp/LiPa_UJpSb dbname='postgres' --file
/home/ashutosh/work/units/pghead/build/dev/testrun/pg_upgrade/002_pg_upgrade/data/tmp_test_X1bh/dump1.sql
[17:08:30.129](1.967s) ok 4 - dump before running pg_upgrade
connection error: 'psql: error: connection to server on socket
"/tmp/LiPa_UJpSb/.s.PGSQL.13779" failed: FATAL: database "regression"
does not exist'
while running '/home/ashutosh/work/units/pghead/build/dev/bin/psql
--no-psqlrc --no-align --tuples-only --quiet --dbname port=13779
host=/tmp/LiPa_UJpSb dbname='regression' --file - --variable
ON_ERROR_STOP=1' at
/home/ashutosh/work/units/pghead/coderoot/pg/src/test/perl/PostgreSQL/Test/Cluster.pm
line 2256.
# Postmaster PID for node "old_node" is 779230
### Stopping node "old_node" using mode immediate
# Running: pg_ctl --pgdata
/home/ashutosh/work/units/pghead/build/dev/testrun/pg_upgrade/002_pg_upgrade/data/t_002_pg_upgrade_old_node_data/pgdata
--mode immediate stop
waiting for server to shut down.... done
server stopped
# No postmaster PID for node "old_node"
# No postmaster PID for node "new_node"
# No postmaster PID for node "dst_node"
[17:08:30.241](0.112s) # Tests were run but no plan was declared and
done_testing() was not seen.
[17:08:30.241](0.000s) # Looks like your test exited with 29 just after 4.
Something is happening at line 492
command_checks_all(
[
'pg_upgrade', '--no-sync',
'--old-datadir' => $oldnode->data_dir,
'--new-datadir' => $newnode->data_dir,
'--old-bindir' => $oldbindir . '/does/not/exist/',
'--new-bindir' => $newbindir,
'--socketdir' => $newnode->host,
'--old-port' => $oldnode->port,
'--new-port' => $newnode->port,
$mode, '--check',
],
1,
[qr{check for ".*?does/not/exist" failed}],
[],
'run of pg_upgrade --check for new instance with incorrect binary path');
because I don't see that test name or the next one being printed in
regress_*.log
--
Best Wishes,
Ashutosh Bapat
On 2025-Apr-04, Ashutosh Bapat wrote:
connection error: 'psql: error: connection to server on socket
"/tmp/LiPa_UJpSb/.s.PGSQL.13779" failed: FATAL: database "regression"
does not exist'
while running '/home/ashutosh/work/units/pghead/build/dev/bin/psql
--no-psqlrc --no-align --tuples-only --quiet --dbname port=13779
host=/tmp/LiPa_UJpSb dbname='regression' --file - --variable
ON_ERROR_STOP=1' at
/home/ashutosh/work/units/pghead/coderoot/pg/src/test/perl/PostgreSQL/Test/Cluster.pm
line 2256.
# Postmaster PID for node "old_node" is 779230
### Stopping node "old_node" using mode immediate
This is saying that Cluster->psql() (line 2256) tried to connect to
database regression and failed unexpectedly. Is your "olddump" file
created with pg_dumpall from a cluster that contains such a database?
If not, then the test isn't broken, you're just not operating it
correctly :-)
Maybe the failure could be clearer: rather than blindly trying to
connect to regression, first see if it exists, and die with a hard
failure ("your old dump must contain database regression") if not.
Alternatively, if the regression database doesn't exist, just skip that
part.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
On Fri, Apr 4, 2025 at 5:23 PM Álvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2025-Apr-04, Ashutosh Bapat wrote:
connection error: 'psql: error: connection to server on socket
"/tmp/LiPa_UJpSb/.s.PGSQL.13779" failed: FATAL: database "regression"
does not exist'
while running '/home/ashutosh/work/units/pghead/build/dev/bin/psql
--no-psqlrc --no-align --tuples-only --quiet --dbname port=13779
host=/tmp/LiPa_UJpSb dbname='regression' --file - --variable
ON_ERROR_STOP=1' at
/home/ashutosh/work/units/pghead/coderoot/pg/src/test/perl/PostgreSQL/Test/Cluster.pm
line 2256.
# Postmaster PID for node "old_node" is 779230
### Stopping node "old_node" using mode immediateThis is saying that Cluster->psql() (line 2256) tried to connect to
database regression and failed unexpectedly. Is your "olddump" file
created with pg_dumpall from a cluster that contains such a database?
If not, then the test isn't broken, you're just not operating it
correctly :-)
My bad, didn't pay attention to that error (even while pasting it) :(.
You are right. I used pg_dump (without --create) to create olddump.
The comment about olddump just mentions dump output. I think we should
mention pg_dumpall there.
Maybe the failure could be clearer: rather than blindly trying to
connect to regression, first see if it exists, and die with a hard
failure ("your old dump must contain database regression") if not.
Alternatively, if the regression database doesn't exist, just skip that
part.
Right. Something like attached?
--
Best Wishes,
Ashutosh Bapat
Attachments:
improve_error_comment.patchtext/x-patch; charset=US-ASCII; name=improve_error_comment.patchDownload
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 311391d7acd..18073a0fefe 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -105,8 +105,8 @@ sub get_dump_for_comparison
# Testing upgrades with an older version of PostgreSQL requires setting up
# two environment variables, as of:
-# - "olddump", to point to a dump file that will be used to set up the old
-# instance to upgrade from.
+# - "olddump", to point to a dump file, usually output of pg_dumpall, that will
+# be used to set up the old instance to upgrade from.
# - "oldinstall", to point to the installation path of the old cluster.
if ( (defined($ENV{olddump}) && !defined($ENV{oldinstall}))
|| (!defined($ENV{olddump}) && defined($ENV{oldinstall})))
@@ -247,6 +247,10 @@ if (defined($ENV{olddump}))
$oldnode->command_ok(
[ 'psql', '--no-psqlrc', '--file' => $olddumpfile, 'postgres' ],
'loaded old dump file');
+
+ $result = $oldnode->safe_psql('postgres',
+ "SELECT count(*) FROM pg_database WHERE datname='regression'");
+ die "old dump must contain database regression" unless $result == 1;
}
else
{