citusdata / citusdata/citus

Deadlock when creating partitions for a distributed table with foreign key to reference table

Open
#4,482 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

Creating partitions for a table with a foreign key to reference table results in a distributed deadlock.
```sql
drop table if exists ref, events;
create table ref (a int primary key);
select create_reference_table('ref');

create table events (event_id bigserial not null, event_time timestamptz not null default now(), a int references ref (a) , payload jsonb) partition by range (event_time);
select create_distributed_table('events','event_id');
select partman.create_parent('public.events', 'event_time', 'native', '1 hour');

ERROR: canceling the transaction since it was involved in a distributed deadlock
CONTEXT: SQL statement "ALTER TABLE public.events ATTACH PARTITION public.events_p2021_01_08_0400 FOR VALUES FROM ('2021-01-08 04:00:00+01') TO ('2021-01-08 05:00:00+01')"
PL/pgSQL function create_partition_time(text,timestamp with time zone[],boolean,boolean) line 243 at EXECUTE
PL/pgSQL function partman.create_parent(text,text,text,text,text[],integer,text,text,boolean,text,text,text[],boolean,text,boolean,boolean) line 472 at assignment
Time: 1822.380 ms (00:01.822)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.