| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com>, Bohyun Lee <bohyun(dot)lee(at)databricks(dot)com> |
| Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically |
| Date: | 2026-10-05 12:38:38 |
| Message-ID: | 6b1afa67-9cc7-4349-a8a5-af9226775396@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 18/08/2026 13:31, Hüseyin Demir wrote:
> Hi,
>
>> v5 resolved this as a dry run rather than a hard block. --check
>> --initdb reports the initdb command it would run and validates the
>> preconditions (correct new-binary version, empty target directory, old
>> cluster reachable) without creating the new cluster. v6 keeps that,
>> and the docs now describe it.
>
> Thanks, appreciated.
Hmm, so without this, when you run "pg_upgrade --check ...", it checks
various things:
$ bin/pg_upgrade --check -d data -b bin -D data-new
Performing Consistency Checks
-----------------------------
Checking cluster versions ok
Checking database connection settings ok
Checking for unsupported encodings ok
Checking database user is the install user ok
Checking for prepared transactions ok
Checking oldestXID and oldestMultiXid consistency ok
Checking for contrib/isn with bigint-passing mismatch ok
Checking logical replication slots ok
Checking subscription state ok
Checking data type usage ok
Checking for objects affected by Unicode update ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
Checking new cluster tablespace directories ok
*Clusters are compatible*
With the --initdb option, it skips all those checks:
$ bin/pg_upgrade --check -d data -b bin -D data-new2 --initdb -B bin
Examining old cluster settings ok
Constructing new cluster initdb command ok
The following initdb command would be run to create the new cluster:
bin/initdb -N -D data-new2 -U heikki --wal-segsize=16
--data-checksums --encoding=UTF8 --locale-provider=libc
--lc-collate=en_GB.UTF-8 --lc-ctype=en_GB.UTF-8
The new cluster would be created with settings matching the old cluster.
Run pg_upgrade --check afterward for the full compatibility check.
That's not good, that essentially means that --check doesn't work with
the --initdb option. Some of the checks check that the new cluster is
compatible with the old cluster, and assuming we run initdb correctly,
there's no need to run those checks with --initdb. But we should still
run all the checks we can on the old cluster.
Another little issue I noticed: Without the --new-bindir/-B option, it
fails to find the binary:
$ bin/pg_upgrade --check -d data -b bin -D data-new2 --initdb
could not find a "pg_upgrade" to execute
pg_upgrade: could not find own program executable
Failure, exiting
The new binary dir is not given, it's supposed to default to the same as
the old one.
- Heikki
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Burd | 2026-10-05 12:39:08 | Re: Let an ordering index scan hand its ORDER BY value to the target list |
| Previous Message | Daniel Gustafsson | 2026-10-05 12:26:17 | Re: Serverside SNI support in libpq |