citusdata / citusdata/citus

distributed deadlock when dropping distributed table referencing a reference table

Open
#3,526 7 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

To reproduce it on `master`: 2c51057013e102f7e5364a7242d66a65ecd524bc :

```sql
SET citus.shard_replication_factor TO 1;
set log_min_messages to DEBUG4;
set client_min_messages to DEBUG4;
SET citus.log_remote_commands TO ON;

CREATE TABLE ref_table (a int primary key);
SELECT create_reference_table('ref_table');

CREATE TABLE dist_table(a int);
SELECT create_distributed_table('dist_table', 'a');

ALTER TABLE dist_table ADD CONSTRAINT fkey FOREIGN KEY(a) REFERENCES ref_table(a);
```
, and, finally running the below:

```sql
-- to reproduce the bug easily
set citus.force_max_query_parallelization to on;

BEGIN;
SELECT COUNT(*) FROM dist_table;
DROP TABLE dist_table;
ROLLBACK;
```
, we have the below error:

```sql
postgres=# DROP TABLE dist_table;
DEBUG: drop auto-cascades to type dist_table
DEBUG: drop auto-cascades to type dist_table[]
DEBUG: drop auto-cascades to trigger truncate_trigger_45324 on table dist_table
DEBUG: drop auto-cascades to constraint fkey on table dist_table
DEBUG: drop auto-cascades to trigger RI_ConstraintTrigger_a_46850 on table ref_table
DEBUG: drop auto-cascades to trigger RI_ConstraintTrigger_a_46851 on table ref_table
DEBUG: drop auto-cascades to trigger RI_ConstraintTrigger_c_46852 on table dist_table
DEBUG: drop auto-cascades to trigger RI_ConstraintTrigger_c_46853 on table dist_table
DEBUG: EventTriggerInvoke 16450
ERROR: canceling the transaction since it was involved in a distributed deadlock
CONTEXT: SQL statement "SELECT master_drop_all_shards(v_obj.objid, v_obj.schema_name, v_obj.object_name)"
PL/pgSQL function citus_drop_trigger() line 19 at PERFORM
```

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.