Re: [PATCH] Corruption Issue: Fix missing tts_tid in ExecForceStoreHeapTuple

From: Greg Burd <greg(at)burd(dot)me>
To: pgsql-hackers(at)postgresql(dot)org
Cc: zhong950419(at)gmail(dot)com, greg(at)burd(dot)me, andres(at)anarazel(dot)de, nik(at)postgres(dot)ai, virender(dot)cse(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, michael(at)paquier(dot)xyz, dilipbalaut(at)gmail(dot)com
Subject: Re: [PATCH] Corruption Issue: Fix missing tts_tid in ExecForceStoreHeapTuple
Date: 2026-10-23 17:00:08
Message-ID: atuP750u3Ye2lST8@floki
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 18 Oct 2026 23:55:36 -0400, shihao zhong <zhong950419(at)gmail(dot)com> wrote:
> Hi Greg,
>
> The thread only tested the FOR UPDATE case with asserts, so I tried
> it on a normal build. After the FOR UPDATE and a restart, the table
> cannot be read or vacuumed:
>
> create table tri (id int, p polygon);
> insert into tri select i, format('((%s,0),(%s,9),(%s,0))',
> i * 10, i * 10 + 9, i * 10 + 9)::polygon
> from generate_series(1, 20) i;
> create index on tri using gist (p);
> vacuum analyze tri;
> set enable_seqscan = off;
> begin;
> select id from tri order by p <-> point(100,4) limit 5 for update;
> rollback;
> checkpoint;
>
> Then restart the server and run
>
> select count(*) from tri;
> ERROR: invalid page in block 1 of relation "base/5/16384"
>
> With v8 the FOR UPDATE returns 5 rows and the count is 20. I think
> it is ready for committer.
>
> Thanks,
> Shihao

Hi Shihao,

Thanks for testing this. v9 is attached. The code is unchanged from v8.
The commit message now describes the damage as above, and I've added you
as Tested-by.

There are two patches this time:

v9-0001 master, and applies as-is to REL_18 down to REL_15
v9-REL_14-0001 the same fix, with both test blocks placed where 14's
gist.sql and postgres_fdw.sql need them

For each of the six branches, without the fix the new tests fail on
exactly their own hunk (gist ctid_not_found 0 -> 4, postgres_fdw 0 -> 1)
and nothing else, and with the fix they pass. On master the full meson
suite passes, 359 tests and none failing.

best.

-greg

Attachment Content-Type Size
v9-REL_14-0001-Maintain-tts_tid-in-ExecForceStoreHeapTuple.patch_ text/plain 11.5 KB
v9-0001-Maintain-tts_tid-in-ExecForceStoreHeapTuple.patch text/plain 11.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Baji Shaik 2026-10-23 17:54:28 [PATCH] Fall back to serializing when parallel apply runs out of DSM segments
Previous Message Greg Burd 2026-10-23 16:30:24 Re: Trying out <stdatomic.h>