Qutaiba Ashqar
Qutaiba Ashqar

Reputation: 11

Issue with Displaying Tenant Statistics in Citus Multi-Tenant Database

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:

  1. Created two tables companies and campaigns, with id in companies and company_id in campaigns as 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');
    
  2. Inserted data into these tables:

    -- Insert data into companies
    -- Insert data into campaigns
    
  3. Executed 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:

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

Upvotes: 0

Views: 73

Answers (1)

Qutaiba Ashqar
Qutaiba Ashqar

Reputation: 11

The solution is that you need to set the citus.stat_tenants_track to "all" in all your nodes to be able to track the statistics. You can put the setting in the postgresql.conf file to be able track the all citus.stat_tenants_track, but it dose not work with me, so I execute this function in the terminal and it worked.

ALTER SYSTEM SET citus.stat_tenants_track TO 'all';
SELECT pg_reload_conf();

Upvotes: 1

Related Questions