citusdata / citusdata/citus

create_distributed_table distributes non-empty table with append/range distribution

Open
#1,627 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

create_distributed_table waits concurrent COPY to append/range distributed table, then it distributed the table(without COPYing local data to shards). We should error out if local table is not empty for append/range distributions

Example test case to reproduce the issue;
```sql
CREATE TABLE append_copy(id integer, data text, int_data int);
```

Session 1;
```sql
BEGIN;
COPY append_copy FROM PROGRAM 'echo 5, f, 5\\n6, g, 6\\n7, h, 7\\n8, i, 8\\n9, j, 9' WITH CSV;
```

Session 2;
```sql
SELECT create_distributed_table('append_copy', 'id', 'append');
```
Session 1;
```sql
COMMIT;
```
Result;
```sql
SELECT * FROM append_copy;
id | data | int_data
----+------+----------
(0 rows)

DELETE FROM pg_dist_partition WHERE logicalrelid = 'append_copy'::regclass;
DELETE 1

SELECT * FROM append_copy;
id | data | int_data
----+------+----------
5 | f | 5
6 | g | 6
7 | h | 7
8 | i | 8
9 | j | 9
(5 rows)
```

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.