mirror of https://github.com/citusdata/citus.git
Round-robin over worker nodes for 0-shard router queries
parent
ae67fa0e52
commit
7ea718fd8d
|
@ -1629,6 +1629,8 @@ PlanRouterQuery(Query *originalQuery, RelationRestrictionContext *restrictionCon
|
||||||
List **placementList, uint64 *anchorShardId, List **relationShardList,
|
List **placementList, uint64 *anchorShardId, List **relationShardList,
|
||||||
bool replacePrunedQueryWithDummy, bool *multiShardModifyQuery)
|
bool replacePrunedQueryWithDummy, bool *multiShardModifyQuery)
|
||||||
{
|
{
|
||||||
|
static uint32 zeroShardQueryRoundRobin = 0;
|
||||||
|
|
||||||
bool isMultiShardQuery = false;
|
bool isMultiShardQuery = false;
|
||||||
List *prunedRelationShardList = NIL;
|
List *prunedRelationShardList = NIL;
|
||||||
DeferredErrorMessage *planningError = NULL;
|
DeferredErrorMessage *planningError = NULL;
|
||||||
|
@ -1730,7 +1732,10 @@ PlanRouterQuery(Query *originalQuery, RelationRestrictionContext *restrictionCon
|
||||||
List *workerNodeList = ActiveReadableNodeList();
|
List *workerNodeList = ActiveReadableNodeList();
|
||||||
if (workerNodeList != NIL)
|
if (workerNodeList != NIL)
|
||||||
{
|
{
|
||||||
WorkerNode *workerNode = (WorkerNode *) linitial(workerNodeList);
|
int workerNodeCount = list_length(workerNodeList);
|
||||||
|
int workerNodeIndex = zeroShardQueryRoundRobin % workerNodeCount;
|
||||||
|
WorkerNode *workerNode = (WorkerNode *) list_nth(workerNodeList,
|
||||||
|
workerNodeIndex);
|
||||||
ShardPlacement *dummyPlacement =
|
ShardPlacement *dummyPlacement =
|
||||||
(ShardPlacement *) CitusMakeNode(ShardPlacement);
|
(ShardPlacement *) CitusMakeNode(ShardPlacement);
|
||||||
dummyPlacement->nodeName = workerNode->workerName;
|
dummyPlacement->nodeName = workerNode->workerName;
|
||||||
|
@ -1738,6 +1743,8 @@ PlanRouterQuery(Query *originalQuery, RelationRestrictionContext *restrictionCon
|
||||||
dummyPlacement->groupId = workerNode->groupId;
|
dummyPlacement->groupId = workerNode->groupId;
|
||||||
|
|
||||||
workerList = lappend(workerList, dummyPlacement);
|
workerList = lappend(workerList, dummyPlacement);
|
||||||
|
|
||||||
|
zeroShardQueryRoundRobin++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue