pgsql: Remove excess assert from InvalidatePossiblyObsoleteSlot()

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove excess assert from InvalidatePossiblyObsoleteSlot()
Date: 2025-06-23 18:44:15
Message-ID: E1uTm9P-0031CR-09@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove excess assert from InvalidatePossiblyObsoleteSlot()

ca307d5cec90 introduced keeping WAL segments by slot's last saved restart LSN.
It also added an assertion that the slot's restart LSN never goes backward.
However, situations when the restart LSN goes backward have been spotted by
buildfarm animals and investigated in the thread.

When pg_receivewal starts the replication, it sets the last replayed LSN to
the beginning of the segment, which is older than what
ReplicationSlotReserveWal() set for the slot. A similar situation can happen
to pg_basebackup. When standby reconnects to the primary, it sends the last
replayed LSN, which might be older than the last confirmed flush LSN. In
both these situations, a concurrent checkpoint may trigger an assert trap.

Based on ideas from Vitaly Davydov <v(dot)davydov(at)postgrespro(dot)ru>,
Hayato Kuroda (Fujitsu) <kuroda(dot)hayato(at)fujitsu(dot)com>,
Vignesh C <vignesh21(at)gmail(dot)com>,
Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>.

Reported-by: Vignesh C <vignesh21(at)gmail(dot)com>
Reported-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CALDaNm3s-jpQTe1MshsvQ8GO%3DTLj233JCdkQ7uZ6pwqRVpxAdw%40mail.gmail.com
Reviewed-by: Vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/70d8a91f82f19d270facd25bb6292a949773dfce

Modified Files
--------------
src/backend/replication/slot.c | 2 --
1 file changed, 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2025-06-23 18:50:15 Re: pgsql: Improve runtime and output of tests for replication slots checkp
Previous Message Andres Freund 2025-06-23 16:26:22 Re: pgsql: Introduce pg_shmem_allocations_numa view