Onur Tirtir 2023-03-08 15:25:36 +03:00 committed by GitHub
parent d82c11f793
commit e3cf7ace7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 2 deletions

View File

@ -1918,6 +1918,10 @@ ErrorIfNodeContainsNonRemovablePlacements(WorkerNode *workerNode)
{ {
int32 groupId = workerNode->groupId; int32 groupId = workerNode->groupId;
List *shardPlacements = AllShardPlacementsOnNodeGroup(groupId); List *shardPlacements = AllShardPlacementsOnNodeGroup(groupId);
/* sort the list to prevent regression tests getting flaky */
shardPlacements = SortList(shardPlacements, CompareGroupShardPlacements);
GroupShardPlacement *placement = NULL; GroupShardPlacement *placement = NULL;
foreach_ptr(placement, shardPlacements) foreach_ptr(placement, shardPlacements)
{ {

View File

@ -5343,8 +5343,7 @@ ActiveShardPlacementLists(List *taskList)
/* /*
* CompareShardPlacements compares two shard placements by their tuple oid; this * CompareShardPlacements compares two shard placements by placement id.
* oid reflects the tuple's insertion order into pg_dist_placement.
*/ */
int int
CompareShardPlacements(const void *leftElement, const void *rightElement) CompareShardPlacements(const void *leftElement, const void *rightElement)
@ -5370,6 +5369,35 @@ CompareShardPlacements(const void *leftElement, const void *rightElement)
} }
/*
* CompareGroupShardPlacements compares two group shard placements by placement id.
*/
int
CompareGroupShardPlacements(const void *leftElement, const void *rightElement)
{
const GroupShardPlacement *leftPlacement =
*((const GroupShardPlacement **) leftElement);
const GroupShardPlacement *rightPlacement =
*((const GroupShardPlacement **) rightElement);
uint64 leftPlacementId = leftPlacement->placementId;
uint64 rightPlacementId = rightPlacement->placementId;
if (leftPlacementId < rightPlacementId)
{
return -1;
}
else if (leftPlacementId > rightPlacementId)
{
return 1;
}
else
{
return 0;
}
}
/* /*
* LeftRotateList returns a copy of the given list that has been cyclically * LeftRotateList returns a copy of the given list that has been cyclically
* shifted to the left by the given rotation count. For this, the function * shifted to the left by the given rotation count. For this, the function

View File

@ -553,6 +553,7 @@ extern bool BinaryOpExpression(Expr *clause, Node **leftOperand, Node **rightOpe
/* helper functions */ /* helper functions */
extern Var * MakeInt4Column(void); extern Var * MakeInt4Column(void);
extern int CompareShardPlacements(const void *leftElement, const void *rightElement); extern int CompareShardPlacements(const void *leftElement, const void *rightElement);
extern int CompareGroupShardPlacements(const void *leftElement, const void *rightElement);
extern bool ShardIntervalsOverlap(ShardInterval *firstInterval, extern bool ShardIntervalsOverlap(ShardInterval *firstInterval,
ShardInterval *secondInterval); ShardInterval *secondInterval);
extern bool ShardIntervalsOverlapWithParams(Datum firstMin, Datum firstMax, extern bool ShardIntervalsOverlapWithParams(Datum firstMin, Datum firstMax,