Should we disallow removing follower workers when placements exists?
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
If you try to remove a primary worker node with placements on it, Citus throws an error:
```SQL
select citus_remove_node('localhost', 9700);
ERROR: cannot remove the last worker node because there are reference tables and it would cause data loss on reference tables
HINT: To proceed, either drop the reference tables or use undistribute_table() function to convert them to local tables
Time: 13.932 ms
```
When we do the same thing for secondaries, Citus allows remove node, and the user can face query errors. See the details [here](https://github.com/citusdata/citus-ha/pull/302#discussion_r610427710):
```
make WORKERS=1 NODES=3 NODES_SECONDARY=1 cluster
-- create a distributed table on the primary coord
psql -p 5501 -c "CREATE TABLE test (a int); SELECT create_distributed_table('test', 'a');" postgres
pg_autoctl drop node --pgdata reader1c --destroy
-- we can read from the primary coordinator
psql -p 5501 -c "SELECT count(*) FROM test" postgres
-- try to read from secondary coordinator fails as expected
psql -p 5503 -c "SELECT count(*) FROM test" postgres
ERROR: there is a shard placement in node group 1 but there are no nodes in that group
Time: 6.525 ms
```
Contributor guide
Assessment
This issue has not been assessed yet.