master_disable_node no longer crashes when given a non-existant node

pull/1506/head
Brian Cloutier 2017-08-03 12:44:03 +03:00 committed by Brian Cloutier
parent 8229a64fe8
commit 37985de85e
3 changed files with 10 additions and 0 deletions

View File

@ -205,6 +205,10 @@ master_disable_node(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
workerNode = FindWorkerNode(nodeName, nodePort);
if (workerNode == NULL)
{
ereport(ERROR, (errmsg("node at \"%s:%u\" does not exist", nodeName, nodePort)));
}
if (WorkerNodeIsPrimary(workerNode))
{

View File

@ -136,6 +136,9 @@ SELECT master_get_active_worker_nodes();
(localhost,57637)
(1 row)
-- try to disable a node which does not exist and see that an error is thrown
SELECT master_disable_node('localhost.noexist', 2345);
ERROR: node at "localhost.noexist:2345" does not exist
-- restore the node for next tests
SELECT master_activate_node('localhost', :worker_2_port);
master_activate_node

View File

@ -52,6 +52,9 @@ INSERT INTO test_reference_table VALUES (1, '1');
SELECT master_disable_node('localhost', :worker_2_port);
SELECT master_get_active_worker_nodes();
-- try to disable a node which does not exist and see that an error is thrown
SELECT master_disable_node('localhost.noexist', 2345);
-- restore the node for next tests
SELECT master_activate_node('localhost', :worker_2_port);