pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of orphaned 2PC files in the future at recovery
Date: Sun, 29 Dec 2024 23:07:50 +0000
Message-ID: <E1tS2Ny-002134-7f@gemulon.postgresql.org> (raw)

Fix handling of orphaned 2PC files in the future at recovery

Before 728bd991c3c4, that has improved the support for 2PC files during
recovery, the initial logic scanning files in pg_twophase was done so as
files in the future of the transaction ID horizon were checked first,
followed by a check if a transaction ID is aborted or committed which
could involve a pg_xact lookup.  After this commit, these checks have
been done in reverse order.

Files detected as in the future do not have a state that can be checked
in pg_xact, hence this caused recovery to fail abruptly should an
orphaned 2PC file in the future of the transaction ID horizon exist in
pg_twophase at the beginning of recovery.

A test is added to check for this scenario, using an empty 2PC with a
transaction ID large enough to be in the future when running the test.
This test is added in 16 and older versions for now.  17 and newer
versions are impacted by a second bug caused by the addition of the
epoch in the 2PC file names.  An equivalent test will be added in these
branches in a follow-up commit, once the second set of issues reported
are fixed.

Author: Vitaly Davydov, Michael Paquier
Discussion: https://postgr.es/m/11e597-676ab680-8d-374f23c0@145466129
Backpatch-through: 13

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d9ade6f2d4cdf95097bbb927f575611b525a2646

Modified Files
--------------
src/backend/access/transam/twophase.c | 16 ++++++++--------
src/test/recovery/t/009_twophase.pl   | 23 +++++++++++++++++++++++
2 files changed, 31 insertions(+), 8 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1tS2Ny-002134-7f@gemulon.postgresql.org>
Permalink:  ../E1tS2Ny-002134-7f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tS2Ny-002134-7f@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix handling of orphaned 2PC files in the future at recovery
  In-Reply-To: <E1tS2Ny-002134-7f@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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