mirror of https://github.com/citusdata/citus.git
Add error checks to detect failed connection and don't ping secondary nodes to detect self reference.pull/5809/head
parent
5fd0ec7dab
commit
56ab64b747
|
@ -283,6 +283,7 @@ citus_add_node(PG_FUNCTION_ARGS)
|
||||||
*/
|
*/
|
||||||
if (workerNode != NULL &&
|
if (workerNode != NULL &&
|
||||||
workerNode->groupId != COORDINATOR_GROUP_ID &&
|
workerNode->groupId != COORDINATOR_GROUP_ID &&
|
||||||
|
workerNode->nodeRole != SecondaryNodeRoleId() &&
|
||||||
IsWorkerTheCurrentNode(workerNode))
|
IsWorkerTheCurrentNode(workerNode))
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("Node cannot add itself as a worker."),
|
ereport(ERROR, (errmsg("Node cannot add itself as a worker."),
|
||||||
|
|
|
@ -658,10 +658,17 @@ IsWorkerTheCurrentNode(WorkerNode *workerNode)
|
||||||
workerNode->workerPort,
|
workerNode->workerPort,
|
||||||
CurrentUserName(),
|
CurrentUserName(),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
const char *command =
|
const char *command =
|
||||||
"SELECT metadata ->> 'server_id' AS server_id FROM pg_dist_node_metadata";
|
"SELECT metadata ->> 'server_id' AS server_id FROM pg_dist_node_metadata";
|
||||||
|
|
||||||
SendRemoteCommand(workerConnection, command);
|
int resultCode = SendRemoteCommand(workerConnection, command);
|
||||||
|
|
||||||
|
if (resultCode == 0)
|
||||||
|
{
|
||||||
|
CloseConnection(workerConnection);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
PGresult *result = GetRemoteCommandResult(workerConnection, true);
|
PGresult *result = GetRemoteCommandResult(workerConnection, true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue