From 6dd413c17424d91ccb3f9df8a95d37ef905c555a Mon Sep 17 00:00:00 2001
From: Alena Vinter <dlaaren8@gmail.com>
Date: Sun, 15 Jun 2025 01:29:23 +0700
Subject: [PATCH 2/2] [PGPRO-11992] [FIX] Removed assertion in walsummarizer

Fixes an edge case in the walsummarizer process where fetching InsertTLI
during a timeline switch could lead to latest_lsn < read_upto (which
becomes walrcv->flushedUpto in this case), previously triggering an
assertion failure. We now handle this safely by replacing the assertion
with conditional logic.
---
 src/backend/postmaster/walsummarizer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c
index 11857356ce4..690a3b17e97 100644
--- a/src/backend/postmaster/walsummarizer.c
+++ b/src/backend/postmaster/walsummarizer.c
@@ -1551,8 +1551,8 @@ summarizer_read_local_xlog_page(XLogReaderState *state,
 				if (private_data->tli == latest_tli)
 				{
 					/* Still the current timeline, update max LSN. */
-					Assert(latest_lsn >= private_data->read_upto);
-					private_data->read_upto = latest_lsn;
+					if (latest_lsn >= private_data->read_upto)
+						private_data->read_upto = latest_lsn;
 				}
 				else
 				{
--
2.51.0

