| From: | Holger Jakobs <holger(at)jakobs(dot)com> |
|---|---|
| To: | PostgreSQL mailing list <pgsql-admin(at)lists(dot)postgresql(dot)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: | 2026-08-12 10:50:57 |
| Message-ID: | f5bb021f-8f45-4825-9b4a-39241ea27a2f@jakobs.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin pgsql-bugs |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-08-12 15:14:16 | 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 |
| Previous Message | Licio Matos | 2026-08-10 12:39:35 | Re: Urgent !!!! Tables inaccessible postgres v17.6 |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-08-12 11:26:14 | Re: BUG #19610: Database won't start if an unrelated process is exist |
| Previous Message | Christoph Berg | 2026-08-12 08:37:18 | Re: COPY TO regression with psql -c |