Merge pull request #2493 from citusdata/allow-adding-node-in-any-group

Refrain from having a strong opinion on maxGroupId.
pull/2505/head
Marco Slot 2018-11-28 16:25:15 +01:00 committed by GitHub
commit a378a11da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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