Assert "target_wal_endrec == divergerec" in pg_rewind

From: Stepan Neretin <slpmcf(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Assert "target_wal_endrec == divergerec" in pg_rewind
Date: 2026-11-16 19:13:25
Message-ID: CA+Yyo5Raa0ePMeN64EPEBwt5n9T2FUr=+O3-LcnbO_5CJuaTGw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

pg_rewind still trips this when the target is a direct ancestor of the
source and stopped earlier on the common timeline.

Assert(target_wal_endrec == divergerec)

An older base backup of the primary is enough to get there.
Assertion builds crash. Otherwise we already say "no rewind
required", which is correct.

Heikki called the Assert bogus in BUG #18575 and posted a remove-it
patch [1], but it never landed. Maxim bumped that thread later [2].
Srinath's recent file-sync / findLastCheckpoint report [3] quotes the
same Assert, though that thread is about the "== divergerec" early
exit, not this "< divergerec" crash.

Attached is a small rebase on current master, with the TAP coverage
folded into "005_same_timeline.pl". No behaviour change outside
assertion builds.

Does this still seem worth committing?

[1]
https://www.postgresql.org/message-id/fe7af87d-b9bf-481a-902c-089c49aa911d@iki.fi
[2]
https://www.postgresql.org/message-id/a4896a62ceab7167824d48b8f0afe01aef6140aa.camel@arenadata.io
[3]
https://www.postgresql.org/message-id/CAFC+b6qpqH4E22-PAemSby8Yv_2Z_8PUy8XrUmpW9Ot_efKdug@mail.gmail.com

Regards,
Stepan Neretin

Attachment Content-Type Size
0002-Extend-same-timeline-TAP-for-ancestor-no-rewind-case.patch text/x-patch 2.8 KB
0001-Remove-bogus-Assert-in-pg_rewind-ancestor-check.patch text/x-patch 1.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-11-16 19:20:54 Re: Use correct collation in pg_trgm
Previous Message Masahiko Sawada 2026-11-16 19:05:00 Re: Add a hook for handling logical decoding messages on subscribers.