Rename per worker

pull/7555/head
EmelSimsek 2024-03-08 14:51:44 +03:00
parent 56e014e64e
commit c48bf5ebaa
No known key found for this signature in database
GPG Key ID: EB13DFB77C32D7D8
3 changed files with 48 additions and 28 deletions

View File

@ -435,7 +435,7 @@ BigIntArrayDatumContains(Datum *array, int arrayLength, uint64 toFind)
* FullShardPlacementList returns a List containing all the shard placements of
* a specific table (excluding the excludedShardArray)
*/
static List *
List *
FullShardPlacementList(Oid relationId, ArrayType *excludedShardArray)
{
List *shardPlacementList = NIL;

View File

@ -50,6 +50,7 @@
#include "distributed/version_compat.h"
#include "distributed/worker_protocol.h"
extern List *FullShardPlacementList(Oid relationId, ArrayType *excludedShardArray);
static char * PartitionBound(Oid partitionId);
static Relation try_relation_open_nolock(Oid relationId);
static List * CreateFixPartitionConstraintsTaskList(Oid relationId);
@ -555,17 +556,31 @@ CreateFixPartitionShardIndexNames(Oid parentRelationId, Oid partitionRelationId,
/* lock metadata before getting placement lists */
LockShardListMetadata(parentShardIntervalList, ShareLock);
MemoryContext localContext = AllocSetContextCreate(CurrentMemoryContext,
"CreateFixPartitionShardIndexNames",
int taskId = 1;
List *shardPlacementList = FullShardPlacementList(parentRelationId, construct_empty_array(INT4OID));
List *workerNodeList = ReadDistNode(true);
/* make sure we have deterministic output for our tests */
workerNodeList = SortList(workerNodeList, CompareWorkerNodes);
MemoryContext localContext = AllocSetContextCreate(CurrentMemoryContext, "CreateFixPartitionShardIndexNames",
ALLOCSET_DEFAULT_SIZES);
MemoryContext oldContext = MemoryContextSwitchTo(localContext);
int taskId = 1;
ShardInterval *parentShardInterval = NULL;
foreach_ptr(parentShardInterval, parentShardIntervalList)
WorkerNode *workerNode = NULL;
foreach_ptr(workerNode, workerNodeList)
{
uint64 parentShardId = parentShardInterval->shardId;
List *shardsOnNode = FilterActiveShardPlacementListByNode(
shardPlacementList, workerNode);
ShardPlacement *shardPlacement = NULL;
foreach_ptr(shardPlacement, shardsOnNode)
{
uint64 parentShardId = shardPlacement->shardId;
List *queryStringList =
WorkerFixPartitionShardIndexNamesCommandList(parentShardId,
@ -594,6 +609,9 @@ CreateFixPartitionShardIndexNames(Oid parentRelationId, Oid partitionRelationId,
ExecuteUtilityTaskList(list_make1(task), localExecutionSupported);
}
break;
}
/* after every iteration, clean-up all the memory associated with it */
MemoryContextReset(localContext);
}

View File

@ -222,4 +222,6 @@ extern void SetupRebalanceMonitor(List *placementUpdateList,
uint64 initialProgressState,
PlacementUpdateStatus initialStatus);
extern List *FullShardPlacementList(Oid relationId, ArrayType *excludedShardArray);
#endif /* SHARD_REBALANCER_H */