pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix possible recovery trouble if TRUNCATE overlaps a checkpoint.
Date: Thu, 24 Mar 2022 19:32:54 +0000
Message-ID: <E1nXTCX-001DGF-R0@gemulon.postgresql.org> (raw)

Fix possible recovery trouble if TRUNCATE overlaps a checkpoint.

If TRUNCATE causes some buffers to be invalidated and thus the
checkpoint does not flush them, TRUNCATE must also ensure that the
corresponding files are truncated on disk. Otherwise, a replay
from the checkpoint might find that the buffers exist but have
the wrong contents, which may cause replay to fail.

Report by Teja Mupparti. Patch by Kyotaro Horiguchi, per a design
suggestion from Heikki Linnakangas, with some changes to the
comments by me. Review of this and a prior patch that approached
the issue differently by Heikki Linnakangas, Andres Freund, Álvaro
Herrera, Masahiko Sawada, and Tom Lane.

Discussion: http://postgr.es/m/BYAPR06MB6373BF50B469CA393C614257ABF00@BYAPR06MB6373.namprd06.prod.outlook.com

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/access/transam/multixact.c  |  6 +++---
src/backend/access/transam/twophase.c   | 12 ++++++-----
src/backend/access/transam/xact.c       |  5 +++--
src/backend/access/transam/xlog.c       | 16 ++++++++++++--
src/backend/access/transam/xloginsert.c |  2 +-
src/backend/catalog/storage.c           | 29 +++++++++++++++++++++++++-
src/backend/storage/buffer/bufmgr.c     |  6 ++++--
src/backend/storage/ipc/procarray.c     | 26 ++++++++++++++++-------
src/backend/storage/lmgr/proc.c         |  4 ++--
src/include/storage/proc.h              | 37 ++++++++++++++++++++++++++++++++-
src/include/storage/procarray.h         |  5 +++--
11 files changed, 120 insertions(+), 28 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1nXTCX-001DGF-R0@gemulon.postgresql.org>
Permalink:  ../E1nXTCX-001DGF-R0@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nXTCX-001DGF-R0@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: rhaas@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix possible recovery trouble if TRUNCATE overlaps a checkpoint.
  In-Reply-To: <E1nXTCX-001DGF-R0@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