amcheck: detect duplicate PostingItem keys in GIN posting trees

From: Stepan Neretin <slpmcf(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: amcheck: detect duplicate PostingItem keys in GIN posting trees
Date: 2026-07-15 12:00:52
Message-ID: CA+Yyo5TGUHKaMF25S5wUp6seOuez_4BnpcnGJzn6VoUuVT_png@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Attachment Content-Type Size
0001-amcheck-Detect-duplicate-PostingItem-keys-in-GIN-pos.patch text/x-patch 3.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2026-07-15 12:10:52 Re: meson vs. llvm bitcode files
Previous Message Noah Misch 2026-07-15 11:56:01 Re: sequencesync worker race with REFRESH SEQUENCES