| From: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix order of bin and data dir checks in pg_upgrade |
| Date: | 2026-10-14 12:54:05 |
| Message-ID: | E1xGyUf-00000001az1-1snh@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Bohyun Lee <bohyun(dot)lee(at)databricks(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-10-14 17:30:32 | pgsql: Fix jsonb_object_agg() and related aggs used as window functions |
| Previous Message | John Naylor | 2026-10-14 11:26:21 | pgsql: Plug holes in SP-GiST quad tree getQuadrant() |