Re: pg_rewind accepts a standby target that ran with wal_log_hints = off

From: Jan Nidzwetzki <jan(at)planetscale(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Tom Pang <tom(at)planetscale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_rewind accepts a standby target that ran with wal_log_hints = off
Date: 2026-12-02 13:46:37
Message-ID: 43057032-7080-461e-96f9-f4e80b8900e6@planetscale.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Zsolt,

Thanks for the patch!

I ran the test from the patch locally. It fails without your code change
and passes with it.

On 28.11.26 12:07, Zsolt Parragi wrote:
> Repro, all nodes without checksums:
>
> 1. primary A with wal_log_hints = on, standbys B and C, C with
> wal_log_hints = off
> 2. open a transaction on A and insert a row, CHECKPOINT
> 3. promote B
> 4. commit on A, C replays it
> 5. CHECKPOINT on A and C (C's minRecoveryPoint has to pass the
> commit), a SELECT on C sets HEAP_XMIN_COMMITTED, CHECKPOINT on A and C
> again to write the page out
> 6. stop C, pg_rewind it from B
>
> pg_rewind succeeds, and the row is visible on C but not on B.

At first, I couldn't reproduce the issue manually since it depends on
timing. But when I added a CHECKPOINT on B after step 3, I could
reproduce it every time.

> With the attached patch the field tracks the standby's own setting:
>
> * starting archive recovery with wal_log_hints = off clears it
> * replaying XLOG_PARAMETER_CHANGE no longer sets it
> * promotion sets it to the current value as before

I have a comment about the documentation change: When promotion happens,
it sets the field to the current setting in XLogReportParameters(), but
the hint bits written by the standby with wal_log_hints set to off are
still on disk. This means that if a standby is restarted with
wal_log_hints on and then promoted, or started without standby.signal,
pg_rewind accepts it again, leading to the same result as in your steps.
This seems like a corner case and seems to be similar to the primary
case you mentioned as not solved. Maybe the documentation should not say
that promotion removes the restriction. What do you think?

Otherwise, it looks good to me.

Best regards
Jan

--
Jan Nidzwetzki
PlanetScale

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message vignesh C 2026-12-02 13:33:36 Re: Show the conflict log table in \dRs+ output