| From: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
|---|---|
| To: | "Maksim(dot)Melnikov" <m(dot)melnikov(at)postgrespro(dot)ru> |
| Cc: | Osama Abdul Qader <osamaabdulqader(dot)cs(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Race between prepared transaction commit and checkpointer |
| Date: | 2026-09-11 08:33:33 |
| Message-ID: | AA348FAC-EB48-4D3C-B5ED-AB1606D5883B@yandex-team.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-09-11 08:42:29 | Re: [DOC] pg_database_size/pg_tablespace_size error on a missing OID |
| Previous Message | Peter Smith | 2026-09-11 08:27:28 | Re: Review items for EXCEPT TABLE publication |