Re: amcheck: detect duplicate PostingItem keys in GIN posting trees

From: Sofia Kopikova <s(dot)kopikova(at)postgrespro(dot)ru>
To: Stepan Neretin <slpmcf(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: amcheck: detect duplicate PostingItem keys in GIN posting trees
Date: 2026-07-16 16:25:39
Message-ID: 609ba3d6-9395-4083-879a-06260a318299@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/15/26 15:00, Stepan Neretin wrote:
> Hi,
>
>   gin_index_check() compares adjacent separator keys on posting-tree
>   internal pages with ItemPointerCompare(...) < 0, so it reports
>   out-of-order keys but misses duplicates.
>
>   Equal separators should not occur: each PostingItem key is the child
>   page's right bound (dataPrepareDownlink), and leaf TIDs are strictly
>   increasing, so siblings must be strictly ascending. dataLocateItem
>   also treats equal keys as an exact match to that downlink. Entry-tree
>   checks already reject equals (>= 0); posting trees should do the same.
>
>   The attached patch changes the comparison to <= 0 and adds a TAP test
>   that corrupts two adjacent keys to be equal.
>
>
>   Best regards, Stepan Neretin.

Thanks for your patch, Stepan!

The fix itself looks good to me, but why don't you make your test in the
same style as other tests? I mean, make 'test' relation name and '2'
block number perl variables, like it's done in the tests above.

--
regards,
Sofia Kopikova
Postgres Professional

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2026-07-16 16:54:11 Re: PG20 Minimum Dependency Thread
Previous Message Jelte Fennema-Nio 2026-07-16 16:09:57 Re: PG20 Minimum Dependency Thread