BUG #17848: Deadlock when running ANALYZE on a table while REINDEX INDEX CONCURRENTLY is running

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: mba(dot)ogolny(at)gmail(dot)com
Subject: BUG #17848: Deadlock when running ANALYZE on a table while REINDEX INDEX CONCURRENTLY is running
Date: 2023-03-16 19:47:53
Message-ID: 17848-fbeac774e88c0183@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17848
Logged by: Marcin Barczyński
Email address: mba(dot)ogolny(at)gmail(dot)com
PostgreSQL version: 13.10
Operating system: Ubuntu
Description:

In order to reproduce, first prepare the data:

DROP TABLE IF EXISTS demo;
CREATE TABLE demo(val BIGINT);
CREATE INDEX demo_idx ON demo(val);
INSERT INTO demo SELECT val FROM generate_series(1, 10000000) val;

Now, in one terminal run:

q=# REINDEX INDEX CONCURRENTLY demo_idx;

And immediately in the other:

q=# ANALYZE demo;

When REINDEX INDEX CONCURRENTLY is about to finish, it fails with:

ERROR: deadlock detected
DETAIL: Process 762797 waits for ShareLock on virtual transaction 4/32405;
blocked by process 752318.
Process 752318 waits for ShareUpdateExclusiveLock on relation 202300 of
database 58517; blocked by process 762797.
HINT: See server log for query details.

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-03-16 20:24:29 BUG #17849: python3-etcd Missing from the postgres common repo for RHEL8
Previous Message Tom Lane 2023-03-16 19:35:15 Re: BUG #17847: Unaligned memory access in ltree_gist