Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically

From: Bohyun Lee <bohyun(dot)lee(at)databricks(dot)com>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Daniel Gustafsson <daniel(at)yesql(dot)se>, shihao zhong <zhong950419(at)gmail(dot)com>, Harrison Booth <harrisontbooth(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, myon(at)debian(dot)org
Subject: Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically
Date: 2026-12-01 13:56:07
Message-ID: CAMPh8Mos3nRgfrtkzB522p-VeG-CkMX8oYjrDx=wKJpAcDFAVg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Refactored the option-handling code in the Debian script patch to simplify
it slightly without changing functionality.

Best regards,
Bohyun

On Thu, Nov 26, 2026 at 7:46 PM Bohyun Lee <bohyun(dot)lee(at)databricks(dot)com>
wrote:

> Hi Heikki, Daniel, and Greg,
>
> As Heikki suggested, I've started with --print-initdb-options because
> Debian's pg_upgradecluster needs it. Indeed, it would be nice to better
> support
> users of Debian’s upgrade scripts, as well as those running pg_upgrade
> directly.
>
> The attached v11 patch adds:
>
> pg_upgrade --print-initdb-options -b /old/bin -d /old/data
>
> It prints one line of shell-quoted initdb arguments, following
> pg_config --configure, with diagnostics on stderr, including the WAL
> segment size, checksum setting, and template0 encoding and locale
> defaults.
>
> Printing can inspect a running or stopped source. It does not check a
> target cluster, so combining it with --check is rejected. After creating
> the target, callers can run ordinary pg_upgrade --check.
>
> I've also attached a postgresql-common companion patch demonstrating how
> pg_upgradecluster can use the printed WAL/checksum settings while
> retaining Debian's maintenance-database selection, locale overrides,
> configuration copying, and hooks.
>
> This preserves the opportunity to set shared_preload_libraries before the
> new server starts. The PG TAP test covers output reuse through a
> normal check and upgrade, shell quoting, and source lifecycle. I also
> tested the patched pg_upgradecluster through a complete upgrade in an
> isolated Debian package layout.
>
> Best,
> Bohyun
>
> On Wed, Nov 25, 2026 at 4:12 PM Greg Sabino Mullane <htamfids(at)gmail(dot)com>
> wrote:
>
>> On Fri, Nov 20, 2026 at 8:11 AM Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
>> wrote:
>>
>>> Setting shared_preload_libraries in the config file.
>>
>>
>> Thanks, that's a good example. While some don't require it and CREATE
>> EXTENSION works fine (e.g. the one I immediately thought of,
>> pg_stat_statements), others do require a middle step (e.g. pg_cron). Your
>> --print-initdb-options and --initdb-only ideas are good, and I lean towards
>> the latter. The other option is to make --initdb smarter. Maybe that means
>> copying the existing conf files over, maybe it means picking pieces out
>> like shared_preload_libraries. At any rate, that's probably a bigger ask
>> than this patch. Perhaps we can just release this patch as is (with a
>> --initdb flag), and have a separate patch that does --initdb-only and/or
>> gives --initdb more brains?
>>
>> Cheers,
>> Greg
>>
>>

Attachment Content-Type Size
v2-postgresql-common-initdb-options.patch application/octet-stream 22.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Nazir Bilal Yavuz 2026-12-01 13:50:42 Re: Switching XLog source from archive to streaming when primary available