Fix possible recovery trouble if TRUNCATE overlaps a checkpoint.
Robert Haas <rhaas@postgresql.org>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/multixact.c | modified | +3 −3 |
| src/backend/access/transam/twophase.c | modified | +7 −5 |
| src/backend/access/transam/xact.c | modified | +3 −2 |
| src/backend/access/transam/xlog.c | modified | +14 −2 |
| src/backend/access/transam/xloginsert.c | modified | +1 −1 |
| src/backend/catalog/storage.c | modified | +28 −1 |
| src/backend/storage/buffer/bufmgr.c | modified | +4 −2 |
| src/backend/storage/ipc/procarray.c | modified | +19 −7 |
| src/backend/storage/lmgr/proc.c | modified | +2 −2 |
| src/include/storage/procarray.h | modified | +3 −2 |
| src/include/storage/proc.h | modified | +36 −1 |
Discussion
- Corruption during WAL replay 75 messages · 2020-03-23 → 2022-03-29