Hint users to call "citus_set_coordinator_host" first (#6425)

If an operation requires having coordinator in pg_dist_node and if that
is not the case, then we automatically add the coordinator into
pg_dist_node if user didn't add any worker nodes yet.

However, if user have already added some worker nodes before, we throw
an error. With this commit, we improve the error thrown in that case.

Closes #6423 based on the discussion made there.

(cherry picked from commit 20847515fa)
pull/6482/head
Onur Tirtir 2022-10-12 18:18:51 +03:00
parent 26ae4b8fb3
commit 452b6a2212
4 changed files with 19 additions and 4 deletions

View File

@ -267,8 +267,11 @@ ErrorIfCoordinatorNotAddedAsWorkerNode()
return;
}
ereport(ERROR, (errmsg("could not find the coordinator node in "
"metadata as it is not added as a worker")));
ereport(ERROR, (errmsg("operation is not allowed when coordinator "
"is not added into metadata"),
errhint("Use \"SELECT citus_set_coordinator_host('"
"<hostname>', '<port>')\" to configure the "
"coordinator hostname and port")));
}

View File

@ -40,7 +40,13 @@ SELECT 1 FROM master_remove_node('localhost', :master_port);
CREATE TABLE citus_local_table_1 (a int primary key);
-- this should fail as coordinator is removed from pg_dist_node
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
ERROR: could not find the coordinator node in metadata as it is not added as a worker
ERROR: operation is not allowed when coordinator is not added into metadata
-- This should also fail as coordinator is removed from pg_dist_node.
--
-- This is not a great place to test this but is one of those places that we
-- have workers in metadata but not the coordinator.
SELECT create_distributed_table_concurrently('citus_local_table_1', 'a');
ERROR: operation is not allowed when coordinator is not added into metadata
-- let coordinator have citus local tables again for next tests
set client_min_messages to ERROR;
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);

View File

@ -239,7 +239,7 @@ master_remove_node
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-1: <... completed>
ERROR: could not find the coordinator node in metadata as it is not added as a worker
ERROR: operation is not allowed when coordinator is not added into metadata
step s2-commit: COMMIT;
master_remove_node
---------------------------------------------------------------------

View File

@ -35,6 +35,12 @@ CREATE TABLE citus_local_table_1 (a int primary key);
-- this should fail as coordinator is removed from pg_dist_node
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
-- This should also fail as coordinator is removed from pg_dist_node.
--
-- This is not a great place to test this but is one of those places that we
-- have workers in metadata but not the coordinator.
SELECT create_distributed_table_concurrently('citus_local_table_1', 'a');
-- let coordinator have citus local tables again for next tests
set client_min_messages to ERROR;
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);