New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make citus_stat_tenants work with schema-based tenants. #6936
Make citus_stat_tenants work with schema-based tenants. #6936
Conversation
e3e140d
to
d76e072
Compare
Codecov Report
@@ Coverage Diff @@
## main #6936 +/- ##
========================================
Coverage 93.27% 93.28%
========================================
Files 272 272
Lines 58137 57942 -195
========================================
- Hits 54230 54049 -181
+ Misses 3907 3893 -14 |
d76e072
to
4923ad4
Compare
aeb2288
to
83b5f0e
Compare
*/ | ||
static void | ||
SetColocationIdAndPartitionKeyValueForTasks(List *taskList, Job *workerJob) | ||
{ | ||
if (workerJob->colocationId != 0 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep the workerJob->colocationId != 0
check, might be a nice optimization for multi shard queries with many tasks.
9e2b205
to
80a52a0
Compare
/* | ||
* if tenantId is NULL, it must be a schema-based tenant and | ||
* we try to get the tenantId from the colocationId to lookup schema name and use it as a tenantId | ||
*/ | ||
if (tenantId == NULL) | ||
{ | ||
if (!IsTenantSchemaColocationGroup(colocationId)) | ||
{ | ||
return; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this check is needed anymore. We only annotate the query if with tenantId=NULL if IsTenantSchemaColocationGroup returned true. So no need to re-check it here again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, except for locally executed queries (ex: queries to reference tables) that directly follow the AttributeTask(..) flow without being annotated. We can move this check to local_executor. Let me know your thoughts.
@@ -683,7 +740,8 @@ FindTenantStats(MultiTenantMonitor *monitor) | |||
for (int i = 0; i < monitor->tenantCount; i++) | |||
{ | |||
TenantStats *tenantStats = &monitor->tenants[i]; | |||
if (strcmp(tenantStats->tenantAttribute, AttributeToTenant) == 0 && | |||
|
|||
if (strncmp(tenantStats->tenantAttribute, AttributeToTenant, MAX_TENANT_ATTRIBUTE_LENGTH) == 0 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a solid reason. I was just curious about its impact on performance. In any case, it's no longer necessary.
c1aaae8
to
0bc4ced
Compare
0bc4ced
to
56691d7
Compare
Co-authored-by: Jelte Fennema <jelte.fennema@microsoft.com>
…gulbiz/schema-based-tenant-monitoring
@@ -173,6 +173,6 @@ DETAIL: drop cascades to table ab | |||
drop cascades to table single_hash_repartition_first | |||
drop cascades to table single_hash_repartition_second | |||
drop cascades to table ref_table | |||
drop cascades to table ref_table_361397 | |||
drop cascades to table ref_table_361399 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you instead fix this by running SET client_min_messages TO WARNING;
before the DROP SCHEMA
? That will make this diff is not necessary anymore.
0585a36
to
dcfe045
Compare
cc11493
to
10d42ca
Compare
…gulbiz/schema-based-tenant-monitoring
10d42ca
to
4dc9d23
Compare
DESCRIPTION: Enabling citus_stat_tenants to support schema-based tenants.
This pull request modifies the existing logic to enable tenant monitoring with schema-based tenants. The changes made are as follows: