Assert "target_wal_endrec == divergerec" in pg_rewind
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]/messages/by-id/fe7af87d-b9bf-481a-902c-089c49aa911d@iki.fi, but it never landed. Maxim bumped that thread later [2]/messages/by-id/a4896a62ceab7167824d48b8f0afe01aef6140aa.camel@arenadata.io.
Srinath's recent file-sync / findLastCheckpoint report [3]/messages/by-id/CAFC+b6qpqH4E22-PAemSby8Yv_2Z_8PUy8XrUmpW9Ot_efKdug@mail.gmail.com 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]: /messages/by-id/fe7af87d-b9bf-481a-902c-089c49aa911d@iki.fi
/messages/by-id/fe7af87d-b9bf-481a-902c-089c49aa911d@iki.fi
[2]: /messages/by-id/a4896a62ceab7167824d48b8f0afe01aef6140aa.camel@arenadata.io
/messages/by-id/a4896a62ceab7167824d48b8f0afe01aef6140aa.camel@arenadata.io
[3]: /messages/by-id/CAFC+b6qpqH4E22-PAemSby8Yv_2Z_8PUy8XrUmpW9Ot_efKdug@mail.gmail.com
/messages/by-id/CAFC+b6qpqH4E22-PAemSby8Yv_2Z_8PUy8XrUmpW9Ot_efKdug@mail.gmail.com
Regards,
Stepan Neretin
Attachments:
t259255_10002-Extend-same-timeline-TAP-for-ancestor-no-rewind-case.patchtext/x-patch; charset=US-ASCII; name=0002-Extend-same-timeline-TAP-for-ancestor-no-rewind-case.patchDownload+49-3
0001-Remove-bogus-Assert-in-pg_rewind-ancestor-check.patchtext/x-patch; charset=US-ASCII; name=0001-Remove-bogus-Assert-in-pg_rewind-ancestor-check.patchDownload+5-4
On 16 Nov 2026, at 20:13, Stepan Neretin <slpmcf@gmail.com> wrote:
Attached is a small rebase on current master, with the TAP coverage
folded into "005_same_timeline.pl". No behaviour change outside
assertion builds.
use warnings FATAL => 'all';
+use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
The proposed TAP test breaks the current model where tests use the
infrastructure in the RewindTest module. Is there a reason why this test
should be different?
Does this still seem worth committing?
From reading over the thread in which Heikki concluded it was a bogus Assert,
I'd say it's still worth committing. I do think the TAP test should be in line
with the other pg_rewind tests though.
--
Daniel Gustafsson
On Fri, Nov 20, 2026 at 2:48 AM Daniel Gustafsson <daniel@yesql.se> wrote:
On 16 Nov 2026, at 20:13, Stepan Neretin <slpmcf@gmail.com> wrote:
Attached is a small rebase on current master, with the TAP coverage
folded into "005_same_timeline.pl". No behaviour change outside
assertion builds.use warnings FATAL => 'all';
+use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;The proposed TAP test breaks the current model where tests use the
infrastructure in the RewindTest module. Is there a reason why this test
should be different?Does this still seem worth committing?
From reading over the thread in which Heikki concluded it was a bogus
Assert,
I'd say it's still worth committing. I do think the TAP test should be in
line
with the other pg_rewind tests though.--
Daniel Gustafsson
Hi Daniel,
Thanks for looking. Folding this into 005 was a mistake.
RewindTest is the usual primary/standby/promote/rewind cycle, and this
needs an older base backup as the target. Same reason 008 skips it. v2
leaves 005 alone and puts the coverage in 012_target_is_ancestor.pl,
along the lines of Heikki's earlier test.
Assert fix itself is unchanged.
Attached.
On Fri, Nov 20, 2026 at 2:48 AM Daniel Gustafsson <daniel@yesql.se> wrote:
On 16 Nov 2026, at 20:13, Stepan Neretin <slpmcf@gmail.com> wrote:
Attached is a small rebase on current master, with the TAP coverage
folded into "005_same_timeline.pl". No behaviour change outside
assertion builds.use warnings FATAL => 'all';
+use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;The proposed TAP test breaks the current model where tests use the
infrastructure in the RewindTest module. Is there a reason why this test
should be different?Does this still seem worth committing?
From reading over the thread in which Heikki concluded it was a bogus
Assert,
I'd say it's still worth committing. I do think the TAP test should be in
line
with the other pg_rewind tests though.--
Daniel Gustafsson
Hi Daniel,
Thanks for looking. Folding this into 005 was a mistake.
RewindTest is the usual primary/standby/promote/rewind cycle, and this
needs an older base backup as the target. Same reason 008 skips it. v2
leaves 005 alone and puts the coverage in 012_target_is_ancestor.pl,
along the lines of Heikki's earlier test.
Assert fix itself is unchanged.
Attached.
Regards,
Stepan Neretin
Attachments:
t259255_4v2-0001-Remove-bogus-Assert-in-pg_rewind-ancestor-check.patchtext/x-patch; charset=US-ASCII; name=v2-0001-Remove-bogus-Assert-in-pg_rewind-ancestor-check.patchDownload+0-8
v2-0002-Add-TAP-test-for-ancestor-no-rewind-cases.patchtext/x-patch; charset=US-ASCII; name=v2-0002-Add-TAP-test-for-ancestor-no-rewind-cases.patchDownload+126-1
On Thu, Nov 19, 2026 at 08:47:51PM +0100, Daniel Gustafsson wrote:
From reading over the thread in which Heikki concluded it was a bogus Assert,
I'd say it's still worth committing. I do think the TAP test should be in line
with the other pg_rewind tests though.
Dropping the assertion sounds good.
My first impression about the test was that it did not seem like it
was worth the cycles, but I'm convinced by its coverage on closer
read: cases for direct ancestors based on backups are interesting to
have.
--
Michael
On 20 Nov 2026, at 08:56, Michael Paquier <michael@paquier.xyz> wrote:
On Thu, Nov 19, 2026 at 08:47:51PM +0100, Daniel Gustafsson wrote:
From reading over the thread in which Heikki concluded it was a bogus Assert,
I'd say it's still worth committing. I do think the TAP test should be in line
with the other pg_rewind tests though.Dropping the assertion sounds good.
Thanks for confirming, I'll go ahead with this.
My first impression about the test was that it did not seem like it
was worth the cycles, but I'm convinced by its coverage on closer
read: cases for direct ancestors based on backups are interesting to
have.
That was my initial reaction too, but I also came to the conclusion that this
test does in fact cover a case which doesn't have good coverage today.
--
Daniel Gustafsson