Make error message more clear if duplicate rows exist on the coordinator and user trying to create a unique index
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
It's reported by a user on public channel.
It is known that Citus doesn't delete the data on the coordinator, if the table has data before distributing it, while distributing the table. Beside, Citus also checks ALTER TABLE commands on the coordinator before sending them to worker nodes. Combining these two may create an error which is not so easy to understand.
```
CREATE TABLE test_table(id int, value_1 int);
INSERT INTO test_table values(1,1);
INSERT INTO test_table values(1,1);
SELECT create_distributed_table('test_table','id');
ALTER TABLE test_table ADD CONSTRAINT "tt_ukey" UNIQUE(id, value_1); -- Errors out due to duplicate rows
ERROR: could not create unique index "tt_ukey"
DETAIL: Key (id, value_1)=(1, 1) is duplicated.
DELETE FROM test_table;
ALTER TABLE test_table ADD CONSTRAINT "tt_ukey" UNIQUE(id, value_1); -- Still errors out due to duplicate rows
ERROR: could not create unique index "tt_ukey"
DETAIL: Key (id, value_1)=(1, 1) is duplicated.
```
It is expected since we do not delete the data on the coordinator (we can delete it by setting citus.enable_ddl_propagation GUC to off), yet it is not clear with the error message. We may error out with more clear message.
Contributor guide
Assessment
This issue has not been assessed yet.