Store TenantsStatsHashKey on the stack

pull/6868/head
Gokhan Gulbiz 2023-05-11 10:28:14 +03:00
parent 7575f362be
commit f88e988542
No known key found for this signature in database
GPG Key ID: 608EF06B6BD1B45B
1 changed files with 6 additions and 6 deletions

View File

@ -706,10 +706,10 @@ CreateTenantStats(MultiTenantMonitor *monitor, TimestampTz queryTime)
*/
EvictTenantsIfNecessary(queryTime);
TenantStatsHashKey *key = (TenantStatsHashKey *) palloc(sizeof(TenantStatsHashKey));
FillTenantStatsHashKey(key, AttributeToTenant, AttributeToColocationGroupId);
TenantStatsHashKey key = {0};
FillTenantStatsHashKey(&key, AttributeToTenant, AttributeToColocationGroupId);
TenantStats *stats = (TenantStats *) hash_search(monitor->tenants, key,
TenantStats *stats = (TenantStats *) hash_search(monitor->tenants, &key,
HASH_ENTER, NULL);
stats->writesInLastPeriod = 0;
@ -733,10 +733,10 @@ CreateTenantStats(MultiTenantMonitor *monitor, TimestampTz queryTime)
static TenantStats *
FindTenantStats(MultiTenantMonitor *monitor)
{
TenantStatsHashKey *key = (TenantStatsHashKey *) palloc(sizeof(TenantStatsHashKey));
FillTenantStatsHashKey(key, AttributeToTenant, AttributeToColocationGroupId);
TenantStatsHashKey key = {0};
FillTenantStatsHashKey(&key, AttributeToTenant, AttributeToColocationGroupId);
TenantStats *stats = (TenantStats *) hash_search(monitor->tenants, key,
TenantStats *stats = (TenantStats *) hash_search(monitor->tenants, &key,
HASH_FIND, NULL);
return stats;