From 7c841b8d924b017cf65c3e3ce631a686bd7afa00 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Wed, 20 Jul 2022 23:13:10 +0200 Subject: [PATCH] Use explicit memory context with hash_create This changes the hash_create calls in the function cache and in the cagg code to use explicit memory context. Without this hash_create will create the hash table in TopMemoryContext potentially leading to memory leaks. --- src/func_cache.c | 5 ++++- tsl/src/continuous_aggs/insert.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/func_cache.c b/src/func_cache.c index 4713873fc..ded672090 100644 --- a/src/func_cache.c +++ b/src/func_cache.c @@ -464,7 +464,10 @@ initialize_func_info() Relation rel; int i; - func_hash = hash_create("func_cache", _MAX_CACHE_FUNCTIONS, &hashctl, HASH_ELEM | HASH_BLOBS); + func_hash = hash_create("func_cache", + _MAX_CACHE_FUNCTIONS, + &hashctl, + HASH_ELEM | HASH_BLOBS | HASH_CONTEXT); rel = table_open(ProcedureRelationId, AccessShareLock); diff --git a/tsl/src/continuous_aggs/insert.c b/tsl/src/continuous_aggs/insert.c index 760481812..81f22dccc 100644 --- a/tsl/src/continuous_aggs/insert.c +++ b/tsl/src/continuous_aggs/insert.c @@ -103,7 +103,7 @@ cache_inval_init() continuous_aggs_cache_inval_htab = hash_create("TS Continuous Aggs Cache Inval", CA_CACHE_INVAL_INIT_HTAB_SIZE, &ctl, - HASH_ELEM | HASH_BLOBS); + HASH_ELEM | HASH_BLOBS | HASH_CONTEXT); }; static int64