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 failures with incorrect epoch handling for 2PC files at reco
Date: Mon, 30 Dec 2024 00:58:34 +0000
Message-ID: <E1tS478-0021zo-41@gemulon.postgresql.org> (raw)

Fix failures with incorrect epoch handling for 2PC files at recovery

At the beginning of recovery, an orphaned two-phase file in an epoch
different than the one defined in the checkpoint record could not be
removed based on the assumptions that AdjustToFullTransactionId() relies
on, assuming that all files would be either from the current epoch or
from the previous epoch.

If the checkpoint epoch was 0 while the 2PC file was orphaned and in the
future, AdjustToFullTransactionId() would underflow the epoch used to
build the 2PC file path.  In non-assert builds, this would create a
WARNING message referring to a 2PC file with an epoch of "FFFFFFFF" (or
UINT32_MAX), as an effect of the underflow calculation, leaving the
orphaned file around.

Some tests are added with dummy 2PC files in the past and the future,
checking that these are properly removed.

Issue introduced by 5a1dfde8334b, that has switched two-phase state
files to use FullTransactionIds.

Reported-by: Vitaly Davydov
Author: Michael Paquier
Reviewed-by: Vitaly Davydov
Discussion: https://postgr.es/m/13b5b6-676c3080-4d-531db900@47931709
Backpatch-through: 17

Branch
------
REL_17_STABLE

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

Modified Files
--------------
src/backend/access/transam/twophase.c | 167 +++++++++++++++++++++++-----------
src/test/recovery/t/009_twophase.pl   |  34 +++++++
2 files changed, 150 insertions(+), 51 deletions(-)



view thread (2+ messages)

Message-ID: <E1tS478-0021zo-41@gemulon.postgresql.org>
Permalink:  ../E1tS478-0021zo-41@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tS478-0021zo-41@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 failures with incorrect epoch handling for 2PC files at reco
  In-Reply-To: <E1tS478-0021zo-41@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