| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() |
| Date: | 2026-11-02 06:21:01 |
| Message-ID: | E1xNlPh-00000001koO-0fAF@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Delay checkpoint start in RecordTransactionAbortPrepared()
ROLLBACK PREPARED flushes its abort record and then updates pg_xact.
Nothing prevented a checkpoint from setting its redo pointer between
these two steps. A crash before the removal of the 2PC state file would
then cause recovery to begin after the abort record and would restore
the transaction as prepared, even though its rollback has been
aknowledged. Standbys could for example replay the abort record, and a
follow-up COMMIT PREPARED on a primary could make them flip a
transaction from aborted to committed.
Losing an abort is harmless for a regular transaction, but not for a
prepared transaction whose 2PC state file is still on disk. This issue
is fixed by setting DELAY_CHKPT_START (delayChkpt in v14) around the
abort record and the pg_xact update, as done for COMMIT PREPARED.
This issue exists since the introduction of 2PC, since d0a89683a3a4.
Author: Shihao Zhong <zhong950419(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com
Backpatch-through: 14
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/bb4eabd6a1ad3b351aefd27163c367e042563bec
Modified Files
--------------
src/backend/access/transam/twophase.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-11-02 06:43:59 | pgsql: Update .abi-compliance-history for hashed SubPlan fix |
| Previous Message | Richard Guo | 2026-11-02 05:42:15 | pgsql: Fix reuse of stale hash tables by duplicated hashed SubPlans |