pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix order of bin and data dir checks in pg_upgrade
Date: Wed, 14 Oct 2026 12:54:05 +0000
Message-ID: <E1xGyUf-00000001az1-1snh@gemulon.postgresql.org> (raw)

Fix order of bin and data dir checks in pg_upgrade

If you called pg_upgrade with a --new-datadir that points to a
configuration-only dir and no --new-bindir option, it would try to
execute "postgres -C data_directory" using the new binary before
resolving the correct path to it.

To fix, check and resolve the binary dirs first, before calling
adjust_data_dir().  For clarity, rename the setup() function to
check_clusters_stopped() to better reflect what it does now.

One consequence of this is that if the binaries are not found, you now
get an error earlier than before, before the pg_upgrade_output.d
directory and the log files have been created.  That's what
necessitated the test change in this commit.  The log files are
important for things like listing unsupported objects in the source
database, but missing binaries feels like a more permanent error,
similar to invalid options or incorrect directory permissions, and it
seems OK to just print the error to stderr for those.

This has been broken forever, but I chose to not backpatch since no
one else has complained, it's a pretty minor issue, and it's easy to
work around by passing the binary dir explicitly.  Maybe later, if
someone in the field runs into this.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Bohyun Lee <bohyun.lee@databricks.com>
Discussion: https://www.postgresql.org/message-id/6894f355-10e4-4756-89ad-ae5987f416a6@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d733fcaf5cac6b88de9417f2b43e51490e36c7b1

Modified Files
--------------
src/bin/pg_upgrade/exec.c              | 21 ++++----------------
src/bin/pg_upgrade/option.c            |  7 ++++---
src/bin/pg_upgrade/pg_upgrade.c        | 36 ++++++++++++++++++++++++----------
src/bin/pg_upgrade/pg_upgrade.h        |  4 +++-
src/bin/pg_upgrade/t/002_pg_upgrade.pl | 31 +++++++----------------------
5 files changed, 44 insertions(+), 55 deletions(-)



Message-ID: <E1xGyUf-00000001az1-1snh@gemulon.postgresql.org>
Permalink:  ../E1xGyUf-00000001az1-1snh@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xGyUf-00000001az1-1snh@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Fix order of bin and data dir checks in pg_upgrade
  In-Reply-To: <E1xGyUf-00000001az1-1snh@gemulon.postgresql.org>
  References: <E1xGyUf-00000001az1-1snh@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox