Skip to content

Commit

Permalink
Refactor probabilistic tracking implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangulbiz committed Jun 11, 2023
1 parent ac90c5d commit 648b53c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/backend/distributed/utils/citus_stat_tenants.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,17 @@ AttributeTask(char *tenantId, int colocationId, CmdType commandType)

MultiTenantMonitor *monitor = GetMultiTenantMonitor();
bool found = false;
hash_search(monitor->tenants, &key, HASH_FIND, NULL);
hash_search(monitor->tenants, &key, HASH_FIND, &found);

int randomValue = rand() % 100;

/* If the tenant is not found in the hash table, we will track the query with a probability of StatTenantsSampleRateForNewTenants.*/
if (!(!found && randomValue < StatTenantsSampleRateForNewTenants))
/* If the tenant is not found in the hash table, we will track the query with a probability of StatTenantsSampleRateForNewTenants. */
if (!found)
{
return;
int randomValue = rand() % 100;
bool shouldTrackQuery = randomValue < StatTenantsSampleRateForNewTenants;
if (!shouldTrackQuery)
{
return;
}
}

AttributeToColocationGroupId = colocationId;
Expand Down

0 comments on commit 648b53c

Please sign in to comment.