0001-Emulating-page-inconsistency-at-a-WAL-redo-Heap-INSE.patch

text/x-patch

Filename: 0001-Emulating-page-inconsistency-at-a-WAL-redo-Heap-INSE.patch
Type: text/x-patch
Part: 0
Message: Re: Add 64-bit XIDs into PostgreSQL 15

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: Emulating page inconsistency at a WAL-redo-Heap/INSERT+INIT operation.
File+
src/backend/access/heap/pruneheap.c 1 1
From 650a90692a6f601057be145c7d62474462de32db Mon Sep 17 00:00:00 2001
From: Evgeny Voropaev <evorop@gmail.com>
Date: Tue, 5 Aug 2025 14:18:37 +0800
Subject: [PATCH] Emulating page inconsistency at a WAL-redo-Heap/INSERT+INIT
 operation.

Replaying problem.
1. Do not apply a fix for this problem or use the xid64 patch of the v64 
version or less.
2. Use the `Emulating page inconsistency at a WAL-redo-Heap/INSERT+INIT
 operation` patch, which implements `repairFragmentation=false` at the
 invocation of `heap_page_prune_and_freeze` from the `heap_page_prune_opt`
 function. It is quite contrived code, but it allows for replaying the problem.
3. Start the 027_stream_regress.pl test with the next command:
   make -C "./src/test/recovery/" check PROVE_TESTS="t/027_stream_regress.pl" PG_TEST_EXTRA="wal_consistency_checking"

As a result, you should see 
```
2025-08-05 14:15:38.196 +08 startup[173535] FATAL:  inconsistent page found, rel 1663/16384/1259, forknum 0, blkno 0
2025-08-05 14:15:38.196 +08 startup[173535] CONTEXT:  WAL redo at 0/3490EF0 for Heap/INSERT+INIT: off: 0, flags: 0x00; blkref #0: rel 1663/16384/1259, blk 0 FPW
```

---
 src/backend/access/heap/pruneheap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index fc8e14a9f25..b6e8771f74b 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -265,7 +265,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
 			 * that during on-access pruning with the current implementation.
 			 */
 			heap_page_prune_and_freeze(relation, buffer, vistest, 0,
-									   NULL, &presult, PRUNE_ON_ACCESS, &dummy_off_loc, NULL, NULL, true);
+									   NULL, &presult, PRUNE_ON_ACCESS, &dummy_off_loc, NULL, NULL, false);
 
 			/*
 			 * Report the number of tuples reclaimed to pgstats.  This is
-- 
2.49.0