Update src/backend/distributed/metadata/node_metadata.c

Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
pull/7720/head
German Eichberger 2025-03-12 14:16:58 -07:00 committed by GitHub
parent 2f87e83f4c
commit 09ab4bdcb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 2 deletions

View File

@ -1678,11 +1678,20 @@ citus_is_primary_node(PG_FUNCTION_ARGS)
bool isPrimary = false;
int32 groupId = GetLocalGroupId();
WorkerNode *workerNode = PrimaryNodeForGroup(groupId, NULL);
if (workerNode != NULL && workerNode->nodeId == GetLocalNodeId())
if (workerNode == NULL)
{
isPrimary = true;
ereport(WARNING, (errmsg("could not find the current node in pg_dist_node"),
errdetail("If this is the coordinator node, consider adding it "
"into the metadata by using citus_set_coordinator_host() "
"UDF. Otherwise, if you're going to use this node as a "
"worker node for a new cluster, make sure to add this "
"node into the metadata from the coordinator by using "
"citus_add_node() UDF."));
PG_RETURN_NULL();
}
isPrimary = workerNode->nodeId == GetLocalNodeId();
PG_RETURN_BOOL(isPrimary);
}