Re: BUG #19093: Behavioral change in walreceiver termination between PostgreSQL 14.17 and 14.18 - Mailing list pgsql-bugs

From Noah Misch
Subject Re: BUG #19093: Behavioral change in walreceiver termination between PostgreSQL 14.17 and 14.18
Date
Msg-id 20251108200307.c3.nmisch@google.com
Whole thread Raw
In response to Re: BUG #19093: Behavioral change in walreceiver termination between PostgreSQL 14.17 and 14.18  (Michael Paquier <michael@paquier.xyz>)
Responses Re: BUG #19093: Behavioral change in walreceiver termination between PostgreSQL 14.17 and 14.18
List pgsql-bugs
On Fri, Oct 31, 2025 at 12:16:21PM +0900, Michael Paquier wrote:
> On Fri, Oct 31, 2025 at 12:07:01AM +0800, Xuneng Zhou wrote:
> > I’ve incorporated both tests and the assertion into the patch applied to master.
> > For earlier stable branches, the test in
> > 040_standby_failover_slots_sync.pl and the assertion for
> > WAL receiver state checking are not included (if Noah agrees too). Please check.
> 
> Thanks for doing that.  I have extracted the test to check the "valid"
> WAL receiver shutdown case, and applied that separately.
> 
> Noah, what do you think?

This just now got to the top of my queue.  Given your commits, you may no
longer need answers to these and other questions on the thread.  If anything
of $SUBJECT is still waiting on me, let me know.

commit 17b2d5e wrote:
>     Fix unconditional WAL receiver shutdown during stream-archive transition
>     
>     Commit b4f584f9d2a1 (affecting v15~, later backpatched down to 13 as of
>     3635a0a35aaf) introduced an unconditional WAL receiver shutdown when
>     switching from streaming to archive WAL sources.  This causes problems
>     during a timeline switch, when a WAL receiver enters WALRCV_WAITING
>     state but remains alive, waiting for instructions.

>     This commit changes the WAL receiver behavior so as the shutdown becomes
>     conditional, with InstallXLogFileSegmentActive being always reset to
>     prevent the regression fixed by b4f584f9d2a1: only terminate the WAL
>     receiver when it is actively streaming (WALRCV_STREAMING,
>     WALRCV_STARTING, or WALRCV_RESTARTING).  When in WALRCV_WAITING state,
>     just reset InstallXLogFileSegmentActive flag to allow archive
>     restoration without killing the process.  WALRCV_STOPPED and
>     WALRCV_STOPPING are not reachable states in this code path.

For the archives, I think the last sentence is incorrect about WALRCV_STOPPED.
Observing WALRCV_STOPPED at this location was the original motivation for
commit b4f584f9d2a1, per its report
(https://www.postgresql.org/message-id/CAFiTN-sE3ry=ycMPVtC+Djw4Fd7gbUGVv_qqw6qfzp=JLvqT3g@mail.gmail.com).
Commit 17b2d5e will handle that case fine, though.



pgsql-bugs by date:

Previous
From: Amit Langote
Date:
Subject: Re: BUG #19099: Conditional DELETE from partitioned table with non-updatable partition raises internal error
Next
From: PG Bug reporting form
Date:
Subject: BUG #19105: Parallel Hash Join crash when work_mem is small