Thread: pgsql: Fix possible recovery trouble if TRUNCATE overlaps a checkpoint.

pgsql: Fix possible recovery trouble if TRUNCATE overlaps a checkpoint.

From
Robert Haas
Date:
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_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/57f618310f837101ba13757baf95bae37e3766ac

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           | 26 +++++++++++++++++++++-
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              | 38 +++++++++++++++++++++++++++++++--
src/include/storage/procarray.h         |  5 +++--
11 files changed, 117 insertions(+), 29 deletions(-)