The function of initializing rel-cache is RelationCacheInitializePhase3 and in
src/backend/utils/cache/relcache.c file.
When initializing the partition description information, we forget to check if
partition key or descriptor is NULL.
Therefore, after the loop restarts, the partition information will be
initialized again, resulting in an infinite loop.
Code:
/*
* Reload partition key and descriptor for a partitioned table.
*/
if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
RelationBuildPartitionKey(relation);
Assert(relation->rd_partkey != NULL);
RelationBuildPartitionDesc(relation);
Assert(relation->rd_partdesc != NULL);
restart = true;
}