Refrain from having a strong opinion on maxGroupId.

When initializing a Citus formation automatically from an external piece of
software such as Citus-HA, the following process process may be used:

  - decide on the groupId in the external software
  - SELECT * FROM master_add_inactive_node('localhost', 9701, groupid => X)

When Citus checks for maxGroupId, it forbids other software to pick their
own group Ids to ues with the master_add_inactive_node() API.

This patch removes the extra testing around maxGroupId.
pull/2493/head
Dimitri Fontaine 2018-11-26 10:23:08 +01:00 committed by Marco Slot
parent 435a036328
commit 5ae2d03881
1 changed files with 0 additions and 38 deletions

View File

@ -62,7 +62,6 @@ static void SetNodeState(char *nodeName, int32 nodePort, bool isActive);
static HeapTuple GetNodeTuple(char *nodeName, int32 nodePort); static HeapTuple GetNodeTuple(char *nodeName, int32 nodePort);
static Datum GenerateNodeTuple(WorkerNode *workerNode); static Datum GenerateNodeTuple(WorkerNode *workerNode);
static int32 GetNextGroupId(void); static int32 GetNextGroupId(void);
static uint32 GetMaxGroupId(void);
static int GetNextNodeId(void); static int GetNextNodeId(void);
static void InsertNodeRow(int nodeid, char *nodename, int32 nodeport, uint32 groupId, static void InsertNodeRow(int nodeid, char *nodename, int32 nodeport, uint32 groupId,
char *nodeRack, bool hasMetadata, bool isActive, Oid nodeRole, char *nodeRack, bool hasMetadata, bool isActive, Oid nodeRole,
@ -965,15 +964,6 @@ AddNodeMetadata(char *nodeName, int32 nodePort, int32 groupId, char *nodeRack,
{ {
groupId = GetNextGroupId(); groupId = GetNextGroupId();
} }
else
{
uint32 maxGroupId = GetMaxGroupId();
if (groupId > maxGroupId)
{
ereport(ERROR, (errmsg("you cannot add a node to a non-existing group")));
}
}
/* if nodeRole hasn't been added yet there's a constraint for one-node-per-group */ /* if nodeRole hasn't been added yet there's a constraint for one-node-per-group */
if (nodeRole != InvalidOid && nodeRole == PrimaryNodeRoleId()) if (nodeRole != InvalidOid && nodeRole == PrimaryNodeRoleId())
@ -1182,34 +1172,6 @@ GetNextGroupId()
} }
/*
* GetMaxGroupId iterates over the worker node hash, and returns the maximum
* group id from the table.
*/
static uint32
GetMaxGroupId()
{
uint32 maxGroupId = 0;
WorkerNode *workerNode = NULL;
HTAB *workerNodeHash = GetWorkerNodeHash();
HASH_SEQ_STATUS status;
hash_seq_init(&status, workerNodeHash);
while ((workerNode = hash_seq_search(&status)) != NULL)
{
uint32 workerNodeGroupId = workerNode->groupId;
if (workerNodeGroupId > maxGroupId)
{
maxGroupId = workerNodeGroupId;
}
}
return maxGroupId;
}
/* /*
* GetNextNodeId allocates and returns a unique nodeId for the node * GetNextNodeId allocates and returns a unique nodeId for the node
* to be added. This allocation occurs both in shared memory and in write * to be added. This allocation occurs both in shared memory and in write