Hi, Peter

On Tue, 22 Jul 2025 at 17:46, Peter Smith <smithpb2...@gmail.com> wrote:
> Hi.
>
> Here are the latest v14 patches.
>
> Changes include:
>
> PATCH 0002.
> - Fixes the enable_seqscan PANIC bug reported by Japin [1]
> - Adds a new regression test case for this
>
> ======
> [1] 
> https://www.postgresql.org/message-id/ME0P300MB04457E24CA8965F008FB2CDBB648A%40ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
>

After some investigation, I found that the VACUUM assertion failures were
caused by an uninitialized HeapTupleFreeze structure.  PFA.

-- 
Regards,
Japin Li

>From 452996a7c9b2ae08df464007ecbb81a728638bbb Mon Sep 17 00:00:00 2001
From: Japin Li <japi...@hotmail.com>
Date: Wed, 23 Jul 2025 11:48:58 +0800
Subject: [PATCH] Initialize HeapTupleFreeze structure prior to use

---
 contrib/vci/expected/bugs.out         |  8 ++++++++
 contrib/vci/sql/bugs.sql              | 10 ++++++++++
 contrib/vci/storage/vci_ros_command.c |  2 +-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/contrib/vci/expected/bugs.out b/contrib/vci/expected/bugs.out
index 2a77ab55214..231fad69f28 100644
--- a/contrib/vci/expected/bugs.out
+++ b/contrib/vci/expected/bugs.out
@@ -10,3 +10,11 @@ SELECT * FROM t1 WHERE id = 100;
  100 | f899139df5e1059396431415e770c6dd
 (1 row)
 
+-- Bug reported by Japin Li that resulted TRAP
+-- See https://www.postgresql.org/message-id/SY8P300MB0442BEC3F5CF432F0121ACC4B642A%40SY8P300MB0442.AUSP300.PROD.OUTLOOK.COM
+CREATE TABLE t2 (id int, info text) WITH (autovacuum_enabled = off);
+CREATE INDEX t2_id_idx ON t2 USING vci (id);
+INSERT INTO t2 SELECT id, 'test' || id FROM generate_series(1, 1000) id;
+DELETE FROM t2 WHERE id % 10 = 0;
+VACUUM t2;
+DROP TABLE t2;
diff --git a/contrib/vci/sql/bugs.sql b/contrib/vci/sql/bugs.sql
index 3db6e6d37e0..cd45756ad00 100644
--- a/contrib/vci/sql/bugs.sql
+++ b/contrib/vci/sql/bugs.sql
@@ -6,3 +6,13 @@ CREATE INDEX t1_id_idx ON t1 USING vci (id);
 INSERT INTO t1 SELECT id, md5(id::text) FROM generate_series(1, 1000) id;
 SET enable_seqscan TO off;
 SELECT * FROM t1 WHERE id = 100;
+
+-- Bug reported by Japin Li that resulted TRAP
+-- See https://www.postgresql.org/message-id/SY8P300MB0442BEC3F5CF432F0121ACC4B642A%40SY8P300MB0442.AUSP300.PROD.OUTLOOK.COM
+
+CREATE TABLE t2 (id int, info text) WITH (autovacuum_enabled = off);
+CREATE INDEX t2_id_idx ON t2 USING vci (id);
+INSERT INTO t2 SELECT id, 'test' || id FROM generate_series(1, 1000) id;
+DELETE FROM t2 WHERE id % 10 = 0;
+VACUUM t2;
+DROP TABLE t2;
diff --git a/contrib/vci/storage/vci_ros_command.c b/contrib/vci/storage/vci_ros_command.c
index b3a802a77a0..e56a5f803c4 100644
--- a/contrib/vci/storage/vci_ros_command.c
+++ b/contrib/vci/storage/vci_ros_command.c
@@ -3324,7 +3324,7 @@ freezeWos(vci_RosCommandContext *comContext, vci_MainRelVar wosType, Snapshot sn
 	BlockNumber nblocks,
 				blkno;
 
-	frozen = palloc(sizeof(HeapTupleFreeze) * MaxHeapTuplesPerPage);
+	frozen = palloc0(sizeof(HeapTupleFreeze) * MaxHeapTuplesPerPage);
 
 	oid = vci_GetMainRelVar(&comContext->info, wosType, 0);
 
-- 
2.43.0

Reply via email to