v2-0002-Bugfix-TODO-FIXME-write-a-better-message.patch
text/x-patch
Filename: v2-0002-Bugfix-TODO-FIXME-write-a-better-message.patch
Type: text/x-patch
Part: 1
Message:
Re: VM corruption on standby
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 v2-0002
Subject: Bugfix TODO FIXME write a better message
| File | + | − |
|---|---|---|
| src/backend/access/heap/heapam.c | 15 | 4 |
From 4617d97e2953fcb5b20bb14750bcc971ed504286 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Thu, 7 Aug 2025 17:04:30 +0300
Subject: [PATCH v2 2/2] Bugfix TODO FIXME write a better message
---
src/backend/access/heap/heapam.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index e5da051aaf0..6e38c9b4d37 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -2135,10 +2135,13 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
{
all_visible_cleared = true;
PageClearAllVisible(BufferGetPage(buffer));
- visibilitymap_clear(relation,
- ItemPointerGetBlockNumber(&(heaptup->t_self)),
- vmbuffer, VISIBILITYMAP_VALID_BITS);
- INJECTION_POINT_CACHED("heap-insert:visibilitymap-clear", NULL);
+
+ /*
+ * Visibility map should be updated *after* logging the change
+ * within the same critical section.
+ *
+ * AALEKSEEV TODO clarify the reason
+ */
}
/*
@@ -2233,6 +2236,14 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
PageSetLSN(page, recptr);
}
+ if (all_visible_cleared)
+ {
+ visibilitymap_clear(relation,
+ ItemPointerGetBlockNumber(&(heaptup->t_self)),
+ vmbuffer, VISIBILITYMAP_VALID_BITS);
+ INJECTION_POINT_CACHED("heap-insert:visibilitymap-clear", NULL);
+ }
+
END_CRIT_SECTION();
UnlockReleaseBuffer(buffer);
--
2.43.0