Hi,

Buildfarm animal sidewinder reported an assertion failure in
GetSnapshotDataReuse() while running 061_recovery_target_prefetch.pl [1].

The problem seems to be that xactCompletionCount was not incremented when
snapshot management switched from KnownAssignedXids to ProcArray at
the end of recovery. So, an older snapshot taken from KnownAssignedXids could
be incorrectly reused because the counter had not changed. If the backend
then took a new transaction snapshot, the "TransactionXmin <= RecentXmin"
assertion failed.

Attached 0001 fixes this by advancing the counter at the transition.
Also it advances the counter when initializing latestCompletedXid,
which could otherwise leave cached snapshots with a stale xmax.

Patch 0002 provides a reproducer using injection points. It reproduces
the assertion failure without 0001 and passes with it. Unfortunately,
the test is somewhat timing-sensitive, so you may need to run it
several times to reproduce the failure.

Thoughts?

Regards,

[1] 
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2026-12-02%2000%3A38%3A12

-- 
Fujii Masao

Attachment: v1-0001-Fix-snapshot-cache-invalidation-at-the-end-of-rec.patch
Description: Binary data

Attachment: v1-0002-Test-snapshot-cache-invalidation-during-promotion.patch
Description: Binary data

Attachment: nocfbot-v1-0001-Fix-snapshot-cache-invalidation-at-the-end-of-rec-v16-v15.patch
Description: Binary data

Reply via email to