pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() 7+ messages / 1 participants [nested] [flat]
* pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() @ 2026-11-02 06:21 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 7+ messages in thread From: Michael Paquier @ 2026-11-02 06:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com Backpatch-through: 14 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/cea96cdfecbf40aa3f12c1c2572c191f27c318d0 Modified Files -------------- src/backend/access/transam/twophase.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() @ 2026-11-02 06:21 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 7+ messages in thread From: Michael Paquier @ 2026-11-02 06:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ee189838f94a8c7a919883c631bd6d1b8c74c5e2 Modified Files -------------- src/backend/access/transam/twophase.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() @ 2026-11-02 06:21 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 7+ messages in thread From: Michael Paquier @ 2026-11-02 06:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3a2fc766272da0621079a66747cd4503ef3ffe1a Modified Files -------------- src/backend/access/transam/twophase.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() @ 2026-11-02 06:21 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 7+ messages in thread From: Michael Paquier @ 2026-11-02 06:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/56e831ea2227b701548899db40a49af17a7ec79c Modified Files -------------- src/backend/access/transam/twophase.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() @ 2026-11-02 06:21 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 7+ messages in thread From: Michael Paquier @ 2026-11-02 06:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() @ 2026-11-02 06:21 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 7+ messages in thread From: Michael Paquier @ 2026-11-02 06:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a39ec399e37b1254fcc058d82f5b35cc23951790 Modified Files -------------- src/backend/access/transam/twophase.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() @ 2026-11-02 06:21 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 7+ messages in thread From: Michael Paquier @ 2026-11-02 06:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@gmail.com> Discussion: https://postgr.es/m/CAGRkXqRhpq=fd8Qf_-Ki1OW7b1iL+o3YuHiHQhLw5RUJy2JGXQ@mail.gmail.com Backpatch-through: 14 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ea1b698f2ecd9a9b1a31452f6412649352c0dbb2 Modified Files -------------- src/backend/access/transam/twophase.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-11-02 06:21 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-02 06:21 pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() Michael Paquier <michael@paquier.xyz> 2026-11-02 06:21 pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() Michael Paquier <michael@paquier.xyz> 2026-11-02 06:21 pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() Michael Paquier <michael@paquier.xyz> 2026-11-02 06:21 pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() Michael Paquier <michael@paquier.xyz> 2026-11-02 06:21 pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() Michael Paquier <michael@paquier.xyz> 2026-11-02 06:21 pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() Michael Paquier <michael@paquier.xyz> 2026-11-02 06:21 pgsql: Delay checkpoint start in RecordTransactionAbortPrepared() Michael Paquier <michael@paquier.xyz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox