Re: BUG #17268: Possible corruption in toast index after reindex index concurrently

From: Andres Freund <andres(at)anarazel(dot)de>
To: Alexey Ermakov <alexey(dot)ermakov(at)dataegret(dot)com>
Cc: Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Peter Geoghegan <pg(at)bowt(dot)ie>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: BUG #17268: Possible corruption in toast index after reindex index concurrently
Date: 2021-11-08 18:53:17
Message-ID: 20211108185317.fz42txmnkqdkpix6@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2021-11-08 10:36:46 -0800, Andres Freund wrote:
> DROP TABLE IF EXISTS wide; CREATE TABLE wide(id serial primary key, wide text);
> pgbench -n -Mprepared -T1000 -f ~/tmp/insert_cci_bug.sql -c 16 -j 16 postgres
>
> in concurrent psql
> SELECT indrelid::regclass, indexrelid::regclass, bt_index_parent_check(indexrelid::regclass, true) FROM pg_index WHERE indrelid = (SELECT reltoastrelid FROM pg_class WHERE oid = 'wide'::regclass);
> REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_331092_index;
>
> usually after 1-3 iterations the index is corrupt. Reproduces both in 13 and
> HEAD.

Oh, wow (or ugh). It narrows down quite a bit. A single pgbench session
running
INSERT INTO wide(wide) SELECT string_agg(g.i::text || random()::text, '') FROM generate_series(1, 500) g(i);

triggers the issue. Sometimes takes quite a few iterations of REINDEX INDEX
CONCURRENTLY, but...

Greetings,

Andres Freund

PS:
to trigger the reindex / validate I use

cat /tmp/ri.sql
\i /tmp/ri.sql
SELECT 'REINDEX INDEX CONCURRENTLY '||indexrelid::regclass FROM pg_index WHERE indrelid = (SELECT reltoastrelid FROM pg_class WHERE oid = 'wide'::regclass) \gexec
SELECT indrelid::regclass, indexrelid::regclass, bt_index_parent_check(indexrelid::regclass, true) FROM pg_index WHERE indrelid = (SELECT reltoastrelid FROM pg_class WHERE oid = 'wide'::regclass);

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2021-11-08 20:36:41 Re: BUG #17268: Possible corruption in toast index after reindex index concurrently
Previous Message Andres Freund 2021-11-08 18:36:46 Re: BUG #17268: Possible corruption in toast index after reindex index concurrently