Re: Read Replica termination occurs when its max_active_replication_origins setting is lower than the primary

Euler Taveira <euler@eulerto.com>

From: "Euler Taveira" <euler@eulerto.com>
To: "Nathan Bossart" <nathandbossart@gmail.com>, "Masahiko Sawada" <sawada.mshk@gmail.com>
Cc: "Nazneen Jafri" <jafrinazneen@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2025-09-17T22:34:56Z
Lists: pgsql-bugs

Attachments

On Wed, Sep 17, 2025, at 1:23 AM, Nathan Bossart wrote:
> I drafted up what that would look like.  One very small nitpick is that it
> messes up the alignment of the pg_controldata output.  Otherwise, it seems
> pretty straightforward.
>

As Masahiko said this behavior is not new in v18 so I wouldn't consider fix it
to v18.

I don't think your patch works for one detail: StartupReplicationOrigin() is
called earlier than CheckRequiredParameterValues(). The
StartupReplicationOrigin() uses max_active_replication_origins to emit the
PANIC message. I didn't check the implications to postpone the
StartupReplicationOrigin(). Maybe an ugly solution is to check the
max_active_replication_origins inside or even before calling
StartupReplicationOrigin().

I'm attaching a script that I used to simulate the issue. Change the GUC name
to simulate the issue in a pre v18.


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/