Re: BUG #17268: Possible corruption in toast index after reindex index concurrently - Mailing list pgsql-bugs

From Andres Freund
Subject Re: BUG #17268: Possible corruption in toast index after reindex index concurrently
Date
Msg-id 20211108183646.r3y6pldylxngxwl4@alap3.anarazel.de
Whole thread Raw
In response to Re: BUG #17268: Possible corruption in toast index after reindex index concurrently  (Alexey Ermakov <alexey.ermakov@dataegret.com>)
Responses Re: BUG #17268: Possible corruption in toast index after reindex index concurrently
List pgsql-bugs
Hi,

On 2021-11-08 17:04:40 +0600, Alexey Ermakov wrote:
> I was told that application inserts rows into given table with queries like:
> 
> INSERT INTO zz (id, body) VALUES (?, ?) ON CONFLICT (id) DO NOTHING
> 
> inside transaction. It's possible to attempt to insert row with same id
> several times inside one transaction (in that case usually that id is new
> one i.e. was not presented in the table before that transaction).
> 
> Hope it could help in some way.

It did. I've managed to reproduce an issue like this. I'm still narrowing down
the reproducer, but here's what I have so far:

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.

Greetings,

Andres Freund

Attachment

pgsql-bugs by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum
Next
From: Andres Freund
Date:
Subject: Re: BUG #17268: Possible corruption in toast index after reindex index concurrently