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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Holger Jakobs <holger(at)jakobs(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)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
Date: 2026-08-12 15:14:16
Message-ID: 2642395.1786547656@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-bugs

[ redirecting to pgsql-bugs ]

Holger Jakobs <holger(at)jakobs(dot)com> writes:
> 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 can reproduce this if (1) I omit -B (and don't give PGBINNEW
either), and (2) the target -D directory is a config-only directory,
that is it contains postgresql.conf but not PG_VERSION. Given (1),
pg_upgrade is supposed to assume that -B should be the directory
that it itself was executed from. However, that is filled in by
setup(), which does not run till after adjust_data_dir(), which is
reaching the "Finding the real data directory" bit because of (2).
So we arrive there with cluster->bindir still NULL, and kaboom.

So the temporary workaround for Holger is to specify -B explicitly,
but somebody needs to rethink the order of initialization steps here.
Maybe just move that bit of setup() into parseCommandLine()?

It looks like this is an error of pretty long standing...

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message mahamood hussain 2026-08-13 08:55:49 Re: Urgent !!!! Tables inaccessible postgres v17.6
Previous Message Holger Jakobs 2026-08-12 10:50:57 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

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-08-12 16:50:09 Re: BUG #19615: COVAR_POP / COVAR_SAMP / REGR_SXY return 0.0 instead of NaN
Previous Message Tom Lane 2026-08-12 12:51:41 Re: BUG #19610: Database won't start if an unrelated process is exist