Re: pg_restore causing deadlocks on partitioned tables - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg_restore causing deadlocks on partitioned tables
Date
Msg-id 1020278.1600093048@sss.pgh.pa.us
Whole thread Raw
In response to pg_restore causing deadlocks on partitioned tables  (Domagoj Smoljanovic <domagoj.smoljanovic@oradian.com>)
Responses Re: pg_restore causing deadlocks on partitioned tables  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Domagoj Smoljanovic <domagoj.smoljanovic@oradian.com> writes:
> I have pg_restore running in parallel (3 or more) and processing large amount of data that is in partitioned tables.
Howeverit seems that sometime deadlock appears when one process is trying to process primary key on parent table while
datastill hasn’t been loaded into partitions. And acquires Exclusive Lock on the whole table. Then another process
comesand tries to load one of the partitions with SharedLock but it fails. 

> This of course doesn’t happen always; depending on the course of actions of the pg_restore. But often enough to cause
frustration.

> Process 15858 waits for AccessShareLock on relation 233358134 of database 233346697; blocked by process 15861.
> Process 15861 waits for AccessExclusiveLock on relation 233374757 of database 233346697; blocked by process 15858.
> Process 15858: TRUNCATE TABLE ONLY myschema."myTable:2020-09-01";
> Process 15861: ALTER TABLE ONLY myschema."myTable" ADD CONSTRAINT "pk_myTable" PRIMARY KEY ("ID", date);

Hm, this seems related to 2ba5b2db7, but not the same thing.
Alvaro, any thoughts?

            regards, tom lane



pgsql-hackers by date:

Previous
From: Konstantin Knizhnik
Date:
Subject: Re: On login trigger: take three
Next
From: Justin Pryzby
Date:
Subject: Re: 回复:how to create index concurrently on partitioned table