pull/7016/merge
Hanefi Onaldi 2025-06-24 11:04:07 -07:00 committed by GitHub
commit 0d8433580c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 3 deletions

View File

@ -2962,7 +2962,7 @@ SyncNodeMetadataToNodesOptional(void)
/* we fetch the same node again to check if it's synced or not */
WorkerNode *nodeUpdated = FindWorkerNode(workerNode->workerName,
workerNode->workerPort);
if (!nodeUpdated->metadataSynced)
if (nodeUpdated == NULL || !nodeUpdated->metadataSynced)
{
/* set the result to FAILED to trigger the sync again */
result = NODE_METADATA_SYNC_FAILED_SYNC;

View File

@ -110,7 +110,7 @@ ActiveReadableNodeCount(void)
* NodeIsCoordinator returns true if the given node represents the coordinator.
*/
bool
NodeIsCoordinator(WorkerNode *node)
NodeIsCoordinator(const WorkerNode *node)
{
return node->groupId == COORDINATOR_GROUP_ID;
}
@ -354,6 +354,9 @@ CompareWorkerNodes(const void *leftElement, const void *rightElement)
* WorkerNodeCompare compares two worker nodes by their host name and port
* number. Two nodes that only differ by their rack locations are considered to
* be equal to each other.
*
* This function also makes sure that coordinator nodes are always considered
* lexicographically smaller than other worker nodes.
*/
int
WorkerNodeCompare(const void *lhsKey, const void *rhsKey, Size keySize)
@ -361,6 +364,15 @@ WorkerNodeCompare(const void *lhsKey, const void *rhsKey, Size keySize)
const WorkerNode *workerLhs = (const WorkerNode *) lhsKey;
const WorkerNode *workerRhs = (const WorkerNode *) rhsKey;
if (NodeIsCoordinator(workerLhs))
{
return -1;
}
if (NodeIsCoordinator(workerRhs))
{
return 1;
}
return NodeNamePortCompare(workerLhs->workerName, workerRhs->workerName,
workerLhs->workerPort, workerRhs->workerPort);
}

View File

@ -96,7 +96,7 @@ extern bool NodeIsPrimaryAndRemote(WorkerNode *worker);
extern bool NodeIsPrimary(WorkerNode *worker);
extern bool NodeIsSecondary(WorkerNode *worker);
extern bool NodeIsReadable(WorkerNode *worker);
extern bool NodeIsCoordinator(WorkerNode *node);
extern bool NodeIsCoordinator(const WorkerNode *node);
extern WorkerNode * SetWorkerColumn(WorkerNode *workerNode, int columnIndex, Datum value);
extern WorkerNode * SetWorkerColumnOptional(WorkerNode *workerNode, int columnIndex, Datum
value);