pgsql: Add assertion check for WAL receiver state during stream-archive

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add assertion check for WAL receiver state during stream-archive
Date: 2025-11-04 04:29:52
Message-ID: E1vG8g4-004vyv-2D@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add assertion check for WAL receiver state during stream-archive transition

When the startup process switches from streaming to archive as WAL
source, we avoid calling ShutdownWalRcv() if the WAL receiver is not
streaming, based on WalRcvStreaming(). WALRCV_STOPPING is a state set
by ShutdownWalRcv(), called only by the startup process, meaning that it
should not be possible to reach this state while in
WaitForWALToBecomeAvailable().

This commit adds an assertion to make sure that a WAL receiver is never
in a WALRCV_STOPPING state should the startup process attempt to reset
InstallXLogFileSegmentActive.

Idea suggested by Noah Misch.

Author: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Discussion: https://postgr.es/m/19093-c4fff49a608f82a0@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/65f4976189b6cbe9aa93fc5f4b1eb7a2040b6301

Modified Files
--------------
src/backend/access/transam/xlogrecovery.c | 8 ++++++++
1 file changed, 8 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2025-11-04 10:00:35 pgsql: Use USECS_PER_SEC from datatype/timestamp.h
Previous Message Michael Paquier 2025-11-04 03:57:55 pgsql: Add WalRcvGetState() to retrieve the state of a WAL receiver