pgstat: Create memory contexts below TopMemoryContext

So far they were created below CacheMemoryContext. However, that's not
guaranteed to exist in all situations, leading to memory contexts created as
top-level contexts. There isn't actually a good reason anymore to create them
below CacheMemoryContext, so just creating them below TopMemoryContext seems
the best approach.

Reported-by: Reid Thompson <reid.thompson@crunchydata.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Author: "Drouvot, Bertrand" <bdrouvot@amazon.com>
Discussion: https://postgr.es/m/b948b729-42fe-f88c-2f4a-0e65d84c049b@amazon.com
Backpatch: 15-
This commit is contained in:
Andres Freund 2022-09-16 14:08:40 -07:00
parent fdd8937c07
commit 9d3ebba729
2 changed files with 3 additions and 3 deletions

View File

@ -1069,7 +1069,7 @@ pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, Oid objoid, bool *created
if (unlikely(!pgStatPendingContext))
{
pgStatPendingContext =
AllocSetContextCreate(CacheMemoryContext,
AllocSetContextCreate(TopMemoryContext,
"PgStat Pending",
ALLOCSET_SMALL_SIZES);
}

View File

@ -992,12 +992,12 @@ pgstat_setup_memcxt(void)
{
if (unlikely(!pgStatSharedRefContext))
pgStatSharedRefContext =
AllocSetContextCreate(CacheMemoryContext,
AllocSetContextCreate(TopMemoryContext,
"PgStat Shared Ref",
ALLOCSET_SMALL_SIZES);
if (unlikely(!pgStatEntryRefHashContext))
pgStatEntryRefHashContext =
AllocSetContextCreate(CacheMemoryContext,
AllocSetContextCreate(TopMemoryContext,
"PgStat Shared Ref Hash",
ALLOCSET_SMALL_SIZES);
}