Simplfy CreateTenantStats()

pull/6868/head
Gokhan Gulbiz 2023-05-10 12:49:43 +03:00
parent 9c4c40217b
commit f53b4cb1f8
No known key found for this signature in database
GPG Key ID: 608EF06B6BD1B45B
1 changed files with 2 additions and 7 deletions

View File

@ -706,12 +706,11 @@ CreateTenantStats(MultiTenantMonitor *monitor, TimestampTz queryTime)
*/
EvictTenantsIfNecessary(queryTime);
bool found;
TenantStatsHashKey *key = CreateTenantStatsHashKey(AttributeToTenant,
AttributeToColocationGroupId);
TenantStats *stats = (TenantStats *) hash_search(monitor->tenants, key,
HASH_ENTER, &found);
HASH_ENTER, NULL);
pfree(key);
@ -724,11 +723,7 @@ CreateTenantStats(MultiTenantMonitor *monitor, TimestampTz queryTime)
stats->score = 0;
stats->lastScoreReduction = 0;
if (!found)
{
/* initialize the stats lock for the new entry in the hash table */
SpinLockInit(&stats->lock);
}
SpinLockInit(&stats->lock);
return stats;
}