v4-0002-Remove-excess-assert-from-InvalidatePossiblyObsol.patch

application/octet-stream

Filename: v4-0002-Remove-excess-assert-from-InvalidatePossiblyObsol.patch
Type: application/octet-stream
Part: 0
Message: Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v4-0002
Subject: Remove excess assert from InvalidatePossiblyObsoleteSlot()
File+
src/backend/replication/slot.c 0 2
From a805b5fc6320069b33c3f60037f32f3e679db5cd Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Wed, 18 Jun 2025 19:34:00 +0300
Subject: [PATCH v4 2/2] 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. As stated in the ReplicationSlotReserveWal() comment, this is not
always true. Additionally, this issue has been spotted by some buildfarm
members.

Vitaly Davydov <v.davydov@postgrespro.ru> proposed the fix idea.

Reported-by: Vignesh C <vignesh21@gmail.com>
Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CALDaNm3s-jpQTe1MshsvQ8GO%3DTLj233JCdkQ7uZ6pwqRVpxAdw%40mail.gmail.com
---
 src/backend/replication/slot.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index c64f020742f..c11e588d632 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -1810,8 +1810,6 @@ InvalidatePossiblyObsoleteSlot(uint32 possible_causes,
 		 */
 		SpinLockAcquire(&s->mutex);
 
-		Assert(s->data.restart_lsn >= s->last_saved_restart_lsn);
-
 		restart_lsn = s->data.restart_lsn;
 
 		/* we do nothing if the slot is already invalid */
-- 
2.39.5 (Apple Git-154)