pg_rewind with --write-recovery-conf option doesn't write dbname to primary_conninfo value.

Masahiko Sawada <sawada.mshk@gmail.com>

From: Masahiko Sawada <sawada.mshk@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-01-29T21:47:08Z
Lists: pgsql-hackers

Attachments

Hi,

I found that pg_rewind with --write-recovery-conf option doesn't write
the dbname to an auto-generated primary_conninfo value. Therefore,
after a failover, the old primary cannot start if it's rewound by
pg_rewind with --write-recovery-conf option if sync_replication_slots
is on. Is it an oversight in commit a145f424d5? I could not see any
discussion in the thread[1] about whether we need to support adding
the dbname to the primary_conninfo value generated by pg_rewind.

I think it's a good idea to support it at least on HEAD. I've attached
a patch for that.

Regards,

[1] https://www.postgresql.org/message-id/CAB8KJ%3DhdKdg%2BUeXhReeHpHA6N6v3e0qFF%2BZsPFHk9_ThWKf%3D2A%40mail.gmail.com

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Commits

  1. pg_rewind: Add dbname to primary_conninfo when using --write-recovery-conf.

  2. Allow dbname to be written as part of connstring via pg_basebackup's -R option.