Hi Maksim, On 11 Sep 2026, Maksim Melnikov wrote: > I am not sure but for example > it can be LookupGXact.
Yes, your suspicion about LookupGXact() is correct. With your patch applied, I could still trigger its Assert(gxact->prepare_start_lsn) by pausing in the WAL branch and completing a checkpoint. Both holders use LW_SHARED, so the checkpoint can proceed. This was a direct call to the helper via a test wrapper, not an end-to-end logical replication test. I also reproduced the original race for both COMMIT PREPARED and ROLLBACK PREPARED. Your fix blocks that interleaving in both cases. Would it be better to take LW_EXCLUSIVE in CheckPointTwoPhase() and protect the state reads in both FinishPreparedTransaction() and LookupGXact() with LW_SHARED? That would address both readers without serializing their I/O under a global exclusive lock. The reader lock would still need to cover the WAL read, not just copying the LSN, because the checkpoint can otherwise proceed to recycling that WAL. Thank you! Best regards, Andrey Borodin.
