Add --system-identifier / -s option to pg_resetwal

From: Nikolay Samokhvalov <nik(at)postgres(dot)ai>
To: pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org>
Subject: Add --system-identifier / -s option to pg_resetwal
Date: 2025-05-31 18:52:19
Message-ID: CAM527d8v+SdwmyCGz9L28GwGVFDYTzdo9QbPVqBDMjdO3VDT8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi hackers,

I was just involved in a DR case, where we needed to change system ID in
control data, and noticed that there is no such capability, officially – so
I thought, it would be good to have it

the attached patch adds a new -s / --system-identifier option to
pg_resetwal that allows users to change the database cluster's system
identifier; it can be useful when you need to make a restored cluster
distinct from the original, or when cloning for testing

some aspects about the patch:
- accepts positive 64-bit integers only (zero not allowed)
- requires interactive confirmation or --force flag for safety
- detects non-TTY environments and requires --force in scripts
- included input validation and error handling
- updated docs with clear warnings about compatibility
- added tests, including some edge cases

looking forward to hearing feedback!

Nik

Attachment Content-Type Size
0001-pg_resetwal--system-identifier.patch application/octet-stream 14.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirk Wolak 2025-05-31 19:31:09 Re: Add --system-identifier / -s option to pg_resetwal
Previous Message Tom Lane 2025-05-31 15:42:01 Re: [PING] fallocate() causes btrfs to never compress postgresql files