Re: pg_upgrade fails with a config-only datadir and no --new-bindir

From: Bohyun Lee <bohyun(dot)lee(at)databricks(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade fails with a config-only datadir and no --new-bindir
Date: 2026-10-14 08:04:53
Message-ID: CAMPh8MqeYMUo+WOcSNdR-WG1+EX_7-2ZvR_r8HqsbQUgUsWQ7g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I think the ordering of checks in main() and setup() is the culprit
> here. main() calls adjust_data_dir() first, which does this:
>
>> snprintf(cmd, sizeof(cmd), "\"%s/postgres\" -D \"%s\" -C
data_directory",
>> cluster->bindir, cluster->pgconfig);
>
> to get the path to the data directory from the config. But
> cluster->bindir isn't initialized yet.

Agreed on the ordering. The main() should first call check_bin_dirs()
to resolve the default new binary directory first and then call
adjust_data_dir()
to find the actual data directory when a configuration-only directory
is specified, and then check_data_dir().

Best regards,
Bohyun

On Wed, Oct 14, 2026 at 9:17 AM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:

> On 14/10/2026 04:39, Chao Li wrote:
> > However, the updated test in 002_pg_upgrade.pl doesn’t seem to cover
> the bug being fixed. I tried to ran the updated test against master, and it
> still passed. Is that intentional?
>
> Yes, I didn't include a test for the bug being fixed. The test change
> was just to reflect that the behavior with a bogus --old-bindir changed
> slightly -- the error on that now occurs earlier, before the
> pg_upgrade_output.d directory is created.
>
> - Heikki
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Chao Li 2026-10-14 07:49:15 Fix pg_restore gzip stream validation (bug #19754)