Cache lookup failure after dropping type used in partition column
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
What we fail to access is the distribution column and its type, because it is dropped from previous `DROP TYPE comp_type CASCADE`. The issue can be reproduced as follows:
```SQL
SET citus.shard_count TO 4;
CREATE TYPE my_type AS (int_field int);
CREATE TABLE tbl (a my_type);
SELECT create_distributed_table('tbl', 'a');
-- the following should error out but it doesn't
-- it drops the distribution column of the table in the coordinator -- OOPS!
-- doesn't propagate anything to shards
DROP TYPE my_type CASCADE;
NOTICE: drop cascades to column a of table tbl
-- OOPS no distribution column
\d+ tbl
Table "public.tbl"
Column | Type | Collation | Nullable | Default
--------+------+-----------+----------+---------
-- shards are still there!!
SELECT run_command_on_workers($$ SELECT json_agg(relname) FROM pg_class WHERE relname LIKE 'tbl%'$$);
run_command_on_workers
----------------------------------------------------------------
(localhost,9701,t,"[""tbl"", ""tbl_102008"", ""tbl_102010""]")
(localhost,9702,t,"[""tbl"", ""tbl_102009"", ""tbl_102011""]")
(2 rows)
SELECT * FROM citus_shards;
ERROR: cache lookup failed for type 17132
DROP TABLE tbl;
ERROR: cache lookup failed for type 17132
```
EDIT: problem already mentioned in https://github.com/citusdata/citus-enterprise/issues/687
_Originally posted by @naisila in https://github.com/citusdata/citus/issues/5780#issuecomment-1263925048_
Contributor guide
Assessment
This issue has not been assessed yet.