Only warn about reference tables when removing last node

pull/5021/head
Marco Slot 2021-06-01 00:55:44 +02:00
parent 056005db4d
commit c03729ad03
3 changed files with 8 additions and 1 deletions

View File

@ -1292,7 +1292,7 @@ RemoveNodeFromCluster(char *nodeName, int32 nodePort)
} }
if (NodeGroupHasLivePlacements(workerNode->groupId)) if (NodeGroupHasLivePlacements(workerNode->groupId))
{ {
if (ClusterHasReferenceTable()) if (ActivePrimaryNodeCount() == 1 && ClusterHasReferenceTable())
{ {
ereport(ERROR, (errmsg( ereport(ERROR, (errmsg(
"cannot remove the last worker node because there are reference " "cannot remove the last worker node because there are reference "

View File

@ -136,6 +136,10 @@ SELECT create_reference_table('test_reference_table');
(1 row) (1 row)
INSERT INTO test_reference_table VALUES (1, '1'); INSERT INTO test_reference_table VALUES (1, '1');
-- try to remove a node with active placements and reference tables
SELECT citus_remove_node('localhost', :worker_2_port);
ERROR: cannot remove the primary node of a node group which has shard placements
HINT: To proceed, either drop the distributed tables or use undistribute_table() function to convert them to local tables
-- try to disable a node with active placements see that node is removed -- try to disable a node with active placements see that node is removed
-- observe that a notification is displayed -- observe that a notification is displayed
SELECT master_disable_node('localhost', :worker_2_port); SELECT master_disable_node('localhost', :worker_2_port);

View File

@ -54,6 +54,9 @@ CREATE TABLE test_reference_table (y int primary key, name text);
SELECT create_reference_table('test_reference_table'); SELECT create_reference_table('test_reference_table');
INSERT INTO test_reference_table VALUES (1, '1'); INSERT INTO test_reference_table VALUES (1, '1');
-- try to remove a node with active placements and reference tables
SELECT citus_remove_node('localhost', :worker_2_port);
-- try to disable a node with active placements see that node is removed -- try to disable a node with active placements see that node is removed
-- observe that a notification is displayed -- observe that a notification is displayed
SELECT master_disable_node('localhost', :worker_2_port); SELECT master_disable_node('localhost', :worker_2_port);