I am experiencing an issue with my Citus multi-tenant database setup, where I am unable to retrieve expected tenant statistics. I am currently running Citus 12.1-1 on an Ubuntu server with a master node and four worker nodes. Below, I provide a detailed description of my setup, the operations I performed, and the issue I am encountering.
Environment:
- Citus Version: 12.1-1
- Host OS: Ubuntu (master and worker nodes)
- Number of Nodes: 1 master, 4 workers
Created two tables
companiesandcampaigns, withidincompaniesandcompany_idincampaignsas distribution columns:CREATE TABLE companies (id BIGSERIAL, name TEXT); SELECT create_distributed_table('companies', 'id'); CREATE TABLE campaigns (id BIGSERIAL, company_id BIGINT, name TEXT); SELECT create_distributed_table('campaigns', 'company_id');Inserted data into these tables:
-- Insert data into companies -- Insert data into campaignsExecuted various SELECT and UPDATE operations on these tables.
Issue:
When querying the citus_stat_tenants view to monitor tenant-related statistics, the expected output is not being displayed. The query used and its result are as follows:
SELECT tenant_attribute, read_count_in_this_period, query_count_in_this_period, cpu_usage_in_this_period
FROM citus_stat_tenants;
Expected Result:
tenant_attribute | read_count_in_this_period | query_count_in_this_period | cpu_usage_in_this_period
------------------+---------------------------+----------------------------+--------------------------
1 | 1 | 5 | 0.000299
3 | 0 | 4 | 0.000314
2 | 1 | 3 | 0.000295
Actual Result:
tenant_attribute | read_count_in_this_period | query_count_in_this_period | cpu_usage_in_this_period
------------------+---------------------------+----------------------------+---------------------
(0 rows)
Attempts to Resolve:
- Verified Citus version (12.1-1).
- Ensured that the tenant ID is correctly implemented and distributed.
- Restarted the PostgreSQL service and checked connections between nodes.
- Monitored for sufficient query activity.
I would appreciate any guidance or assistance you can provide to resolve this issue. Specifically, I am looking to understand why the citus_stat_tenants view is not displaying the expected tenant statistics and any steps I might take to troubleshoot or correct this.
Thanks.
Expected Result:
tenant_attribute | read_count_in_this_period | query_count_in_this_period | cpu_usage_in_this_period
------------------+---------------------------+----------------------------+--------------------------
1 | 1 | 5 | 0.000299
3 | 0 | 4 | 0.000314
2 | 1 | 3 | 0.000295
The solution is that you need to set the
citus.stat_tenants_trackto"all"in all your nodes to be able to track the statistics. You can put the setting in thepostgresql.conffile to be able track the allcitus.stat_tenants_track, but it dose not work with me, so I execute this function in the terminal and it worked.