From 1de65d7771acf90bcc032a87690017608efc1e6f Mon Sep 17 00:00:00 2001
From: Stepan Neretin <slpmcf@gmail.com>
Date: Fri, 20 Nov 2026 14:29:34 +0700
Subject: [PATCH v2 1/2] Remove bogus Assert in pg_rewind ancestor check

When the target is a direct ancestor of the source, its WAL can end
before the calculated divergence LSN, for example after an older base
backup of the primary.  That used to trip
Assert(target_wal_endrec == divergerec) on assertion builds.  Drop it;
we already report "no rewind required".

Discussion: https://postgr.es/m/CA+Yyo5Raa0ePMeN64EPEBwt5n9T2FUr=+O3-LcnbO_5CJuaTGw@mail.gmail.com
---
 src/bin/pg_rewind/pg_rewind.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index d2521dab333..c4ac20be5e0 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -447,16 +447,9 @@ main(int argc, char **argv)
 		 * in the target that needs rewinding.
 		 */
 		if (target_wal_endrec > divergerec)
-		{
 			rewind_needed = true;
-		}
 		else
-		{
-			/* the last common checkpoint record must be part of target WAL */
-			Assert(target_wal_endrec == divergerec);
-
 			rewind_needed = false;
-		}
 	}
 
 	if (!rewind_needed)
-- 
2.56.0

