agora inbox for pgsql-admin@postgresql.org
help / color / mirror / Atom feedFrom: Holger Jakobs <holger@jakobs.com>
To: PostgreSQL mailing list <pgsql-admin@lists.postgresql.org>
Subject: pg_upgrade from 17.10 to 18.4 on Ubuntu fails: Finding the real data directory for the target cluster sh: 1: (null)/postgres: not found
Date: Wed, 12 Aug 2026 12:50:57 +0200
Message-ID: <f5bb021f-8f45-4825-9b4a-39241ea27a2f@jakobs.com> (raw)
Dear Friends,
Today a pg_upgrade failed with this awkward message:
Finding the real data directory for the source cluster ok
Finding the real data directory for the target cluster sh: 1:
(null)/postgres: not found
I checked the source code of pg_upgrade.c and thus options.c and found
that the (null) above stems from an uninitialised variable called cmd,
declared in line 433 of option.c
Line 468 reads:
snprintf(cmd, sizeof(cmd), "\"%s/postgres\" -D \"%s\" -C
data_directory",
cluster->bindir, cluster->pgconfig);
Calling the postgres binary (from the package, didn't compile myself)
works fine and gives me the correct real data directory:
$ /usr/lib/postgresql/18/bin/postgres -D /etc/postgresql/18/main -C
data_directory
/var/lib/postgresql/18/main
So how come that cmd is NULL in line 468? I actually cannot find where
the variable was given any content, so it's NULL. This generates the
error message with "(null)/postgres not found"
Obviously, cmd should contain the path of the oldbin directory, which is
to be derived from the path of the pg_upgrade being called. I didn't use
the -B option because the documentation says that it's optional and will
use the directory of pg_upgrade.
https://www.postgresql.org/docs/current/pgupgrade.html tells me:
| -B| /|bindir|/
| --new-bindir=|/|bindir
|/ the new PostgreSQL executable directory; default is the
directory where pg_upgrade resides
Obviously, this doesn't work as described.
When giving the path to the new bin directory with -B, pg_upgrade works
fine.
Please correct the code so that cmd gets initialised or alter the
documentation making the option -B mandatory.
Kind Regards,
Holger
--
Holger Jakobs, Bergisch Gladbach, Germany
view thread (3+ messages) latest in thread
Message-ID: <f5bb021f-8f45-4825-9b4a-39241ea27a2f@jakobs.com>
Permalink: ../f5bb021f-8f45-4825-9b4a-39241ea27a2f@jakobs.com/
Also on: postgresql.org/message-id/f5bb021f-8f45-4825-9b4a-39241ea27a2f@jakobs.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: holger@jakobs.com, pgsql-admin@lists.postgresql.org
Subject: Re: pg_upgrade from 17.10 to 18.4 on Ubuntu fails: Finding the real data directory for the target cluster sh: 1: (null)/postgres: not found
In-Reply-To: <f5bb021f-8f45-4825-9b4a-39241ea27a2f@jakobs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox