Re: IRe: BUG #16792: silent corruption of GIN index resulting in SELECTs returning non-matching rows

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Pawel Kudzia <kudzia(at)gmail(dot)com>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: IRe: BUG #16792: silent corruption of GIN index resulting in SELECTs returning non-matching rows
Date: 2021-07-20 15:34:57
Message-ID: 8b21e29c-f236-ef40-452f-3fb829b37990@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 20/07/2021 15:22, Pawel Kudzia wrote:
> On Tue, Jul 20, 2021 at 1:55 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>> Pawel: Could you try the attached version of amcheck? Please apply the
>> attached patch (you'll have to un-apply the previous version or start
>> from a clean source tree), run "SELECT
>> gin_index_parent_check('entity_attribute_name_ids_gin');" again, and
>> send over the result? It should print a bunch of INFOs and WARNINGs to
>> the client's stderr, so a good way to capture that is something like this:
>>
>> psql -c "select
>> gin_index_parent_check('entity_attribute_name_ids_gin');" 2> amcheck-log
>>
>
> i'm attaching log of postgresql generated while running the command
> above and amcheck-log.
>
> thanks a lot!

Great! So it's reporting two kinds of issues. First this:

WARNING: index "entity_attribute_name_ids_gin": tid exceeds parent's
high key in postingTree leaf on block 343573

I looked at the amcheck code again, and that is in fact bogus; there is
nothing wrong with the high keys, but there is a memory management bug
in the amcheck patch that's causing it.

The other error it complains about looks like this:

...
INFO: key (1743225, 6) -> 363962
INFO: key (1746295, 15) -> 341281
INFO: key (1747712, 12) -> 343607
INFO: key (1749215, 4) -> 376056
INFO: key (262563, 1) -> 11547
INFO: key (3906513777, 43269) -> 31653888
INFO: key (536354808, 8196) -> 4432
ERROR: index "entity_attribute_name_ids_gin" has wrong tuple order in
posting tree, block 371806, offset 818

Looking at the amcheck code for that check, that's a false alarm too.
amcheck is calculating the size of this array incorrectly, thinking that
there are more entries on the page than there really are. The entries
above up to (1749215, 4) are valid, but the rest are not real entries,
just amcheck's misinterpretation. Unfortunately 'amcheck' stopped at
that error again.

Sigh. I fixed those issues in amcheck again. And also added some more
checks on the high keys. At least we're making the amcheck patch better,
even if we're not any wiser about the original issue...

Pawel: Can you test once again with the attached amcheck version?

- Heikki

Attachment Content-Type Size
v4-0001-Amcheck-for-GIN-13stable.patch text/x-patch 39.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Borodin 2021-07-20 19:25:29 Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Previous Message Pawel Kudzia 2021-07-20 12:22:35 Re: IRe: BUG #16792: silent corruption of GIN index resulting in SELECTs returning non-matching rows