Try copying shard intervals out of cache for long lived borrow

pull/3779/head
Philip Dubé 2020-04-17 19:38:28 +00:00
parent a461ef20d9
commit 8e79672839
1 changed files with 30 additions and 1 deletions

View File

@ -210,8 +210,37 @@ CoordinatorInsertSelectExecScanInternal(CustomScanState *node)
distSelectJob->jobId);
char *distResultPrefix = distResultPrefixString->data;
CitusTableCacheEntry *targetRelation =
CitusTableCacheEntry *cachedTargetRelation =
GetCitusTableCacheEntry(targetRelationId);
CitusTableCacheEntry *targetRelation = palloc(sizeof(CitusTableCacheEntry));
*targetRelation = *cachedTargetRelation;
#if PG_USE_ASSERT_CHECKING
/*
* These fields aren't used in the code which follows,
* therefore in assert builds NULL these fields to
* segfault if they were to be used.
*/
targetRelation->partitionKeySTring = NULL;
targetRelation->shardIntervalCompareFunction = NULL;
targetRelation->hashFunction = NULL;
targetRelation->arrayOfPlacementArrayLengths = NULL;
targetRelation->arrayOfPlacementArrays = NULL;
targetRelation->referencedRelationViaForeignKey = NULL;
targetRelation->referencingRelationsViaForeignKey = NULL;
#endif
targetRelation->partitionColumn = copyObject(
cachedTargetRelation->partitionColumn);
targetRelation->sortedShardIntervalArray =
palloc(targetRelation->shardIntervalArrayLength * sizeof(ShardInterval));
for (int shardIndex = 0; shardIndex <
targetRelation->shardIntervalArrayLength; shardIndex++)
{
targetRelation->sortedShardIntervalArray[shardIndex] =
CopyShardInterval(
cachedTargetRelation->sortedShardIntervalArray[shardIndex]);
}
int partitionColumnIndex =
PartitionColumnIndex(insertTargetList, targetRelation->partitionColumn);