Thread

  1. Re: Add --system-identifier / -s option to pg_resetwal

    Kirk Wolak <wolakk@gmail.com> — 2025-05-31T19:31:09Z

    On Sat, May 31, 2025 at 2:52 PM Nikolay Samokhvalov <nik@postgres.ai> wrote:
    
    > 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!
    >
    +1
    
    Like the idea.  I did a manual code review.  It's a small patch, very
    focused, and includes the proper docs.
    It's very well thought out (I Iike the --force requirement for scripts).
    
    The only thing I saw was that the code basically accepts Y or y, and all
    else is considered "N".  for that reason,
    I suggest that this line:
    printf(_("Continue? (y/n) "));
    
    Would be more clear as:
    printf(_("Continue? (y/n) [n]"));
    
    indicating the N is the default answer.  if you put anything other than Y
    or y... N will be picked.
    
    But this is almost trivial, but I wanted to be thorough.
    
    Regards!