no_lsn_tli_on_zero_page-v81.patch
application/octet-stream
Filename: no_lsn_tli_on_zero_page-v81.patch
Type: application/octet-stream
Part: 2
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: unified
Series: patch v81
| File | + | − |
|---|---|---|
| src/backend/access/heap/heapam.c | 10 | 2 |
| src/backend/commands/tablecmds.c | 9 | 2 |
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index e61b92c..a3d7eeb 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -2740,8 +2740,16 @@ heap_xlog_newpage(XLogRecPtr lsn, XLogRecord *record)
Assert(record->xl_len == SizeOfHeapNewpage + BLCKSZ);
memcpy(page, (char *) xlrec + SizeOfHeapNewpage, BLCKSZ);
- PageSetLSN(page, lsn);
- PageSetTLI(page, ThisTimeLineID);
+ /*
+ * The page may be uninitialized. If so, we can't set the LSN
+ * and TLI because that would corrupt the page.
+ */
+ if (!PageIsNew(page))
+ {
+ PageSetLSN(page, lsn);
+ PageSetTLI(page, ThisTimeLineID);
+ }
+
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
}
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 76722dc..d451e50 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -5893,8 +5893,15 @@ copy_relation_data(Relation rel, SMgrRelation dst)
recptr = XLogInsert(RM_HEAP_ID, XLOG_HEAP_NEWPAGE, rdata);
- PageSetLSN(page, recptr);
- PageSetTLI(page, ThisTimeLineID);
+ /*
+ * The page may be uninitialized. If so, we can't set the LSN
+ * and TLI because that would corrupt the page.
+ */
+ if (!PageIsNew(page))
+ {
+ PageSetLSN(page, recptr);
+ PageSetTLI(page, ThisTimeLineID);
+ }
END_CRIT_SECTION();
}