From 09ab4bdcb38b91d2aca6b46dc987e7d8e902d57c Mon Sep 17 00:00:00 2001 From: German Eichberger Date: Wed, 12 Mar 2025 14:16:58 -0700 Subject: [PATCH] Update src/backend/distributed/metadata/node_metadata.c Co-authored-by: Onur Tirtir --- src/backend/distributed/metadata/node_metadata.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/backend/distributed/metadata/node_metadata.c b/src/backend/distributed/metadata/node_metadata.c index bd02d6ae4..4c38c76fe 100644 --- a/src/backend/distributed/metadata/node_metadata.c +++ b/src/backend/distributed/metadata/node_metadata.c @@ -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); }