Skip to content

Commit

Permalink
Rename citus stats tenants (#6821)
Browse files Browse the repository at this point in the history
Rename some objects
`*citus_stats_tenants*` to `*citus_stat_tenants*`
`citus_stats_tenants*` and `citus_stat_tenants*` GUCs to `stat_tenants*`
`MultiTenantMonitoringLogLevel` to `CitusStatTenantsLogLevel`
`multi_tenant_monitoring_log_level` to `citus.stat_tenants_log_level`
`attribute` files to `citus_stat_tenants`
  • Loading branch information
halilozanakgul authored Apr 4, 2023
1 parent e302be1 commit aeb604b
Show file tree
Hide file tree
Showing 30 changed files with 332 additions and 332 deletions.
2 changes: 1 addition & 1 deletion src/backend/distributed/executor/local_executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@
#include "distributed/relation_access_tracking.h"
#include "distributed/remote_commands.h" /* to access LogRemoteCommands */
#include "distributed/transaction_management.h"
#include "distributed/utils/citus_stat_tenants.h"
#include "distributed/version_compat.h"
#include "distributed/worker_protocol.h"
#include "executor/tstoreReceiver.h"
#include "executor/tuptable.h"
#include "optimizer/optimizer.h"
#include "nodes/params.h"
#include "utils/snapmgr.h"
#include "distributed/utils/attribute.h"

/* controlled via a GUC */
bool EnableLocalExecution = true;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/planner/deparse_shard_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "distributed/multi_physical_planner.h"
#include "distributed/multi_router_planner.h"
#include "distributed/shard_utils.h"
#include "distributed/utils/attribute.h"
#include "distributed/utils/citus_stat_tenants.h"
#include "distributed/version_compat.h"
#include "lib/stringinfo.h"
#include "nodes/makefuncs.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/planner/distributed_planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "distributed/recursive_planning.h"
#include "distributed/shardinterval_utils.h"
#include "distributed/shard_utils.h"
#include "distributed/utils/attribute.h"
#include "distributed/utils/citus_stat_tenants.h"
#include "distributed/version_compat.h"
#include "distributed/worker_shard_visibility.h"
#include "executor/executor.h"
Expand Down
56 changes: 28 additions & 28 deletions src/backend/distributed/shared_library_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
#include "distributed/resource_lock.h"
#include "distributed/transaction_management.h"
#include "distributed/transaction_recovery.h"
#include "distributed/utils/attribute.h"
#include "distributed/utils/citus_stat_tenants.h"
#include "distributed/utils/directory.h"
#include "distributed/worker_log_messages.h"
#include "distributed/worker_manager.h"
Expand Down Expand Up @@ -1961,16 +1961,6 @@ RegisterCitusConfigVariables(void)
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomEnumVariable(
"citus.multi_tenant_monitoring_log_level",
gettext_noop("Sets the level of multi tenant monitoring log messages"),
NULL,
&MultiTenantMonitoringLogLevel,
CITUS_LOG_LEVEL_OFF, log_level_options,
PGC_USERSET,
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomIntVariable(
"citus.next_cleanup_record_id",
gettext_noop("Set the next cleanup record ID to use in operation creation."),
Expand Down Expand Up @@ -2355,40 +2345,50 @@ RegisterCitusConfigVariables(void)
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomEnumVariable(
"citus.stat_tenants_track",
gettext_noop("Enables/Disables the stats collection for citus_stat_tenants."),
gettext_noop("Enables the stats collection when set to 'all'. "
"Disables when set to 'none'. Disabling can be useful for "
"avoiding extra CPU cycles needed for the calculations."),
&StatTenantsTrack,
STAT_TENANTS_TRACK_ALL,
stat_tenants_track_options,
PGC_SUSET,
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomIntVariable(
"citus.stats_tenants_limit",
"citus.stat_tenants_limit",
gettext_noop("Number of tenants to be shown in citus_stat_tenants."),
NULL,
&CitusStatsTenantsLimit,
&StatTenantsLimit,
10, 1, 100,
PGC_POSTMASTER,
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomEnumVariable(
"citus.stat_tenants_log_level",
gettext_noop("Sets the level of citus_stat_tenants log messages"),
NULL,
&StatTenantsLogLevel,
CITUS_LOG_LEVEL_OFF, log_level_options,
PGC_USERSET,
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomIntVariable(
"citus.stats_tenants_period",
"citus.stat_tenants_period",
gettext_noop("Period in seconds to be used for calculating the tenant "
"statistics in citus_stat_tenants."),
NULL,
&CitusStatsTenantsPeriod,
&StatTenantsPeriod,
60, 1, 1000000000,
PGC_USERSET,
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomEnumVariable(
"citus.stat_tenants_track",
gettext_noop("Enables/Disables the stats collection for citus_stat_tenants."),
gettext_noop("Enables the stats collection when set to 'all'. "
"Disables when set to 'none'. Disabling can be useful for "
"avoiding extra CPU cycles needed for the calculations."),
&StatTenantsTrack,
STAT_TENANTS_TRACK_ALL,
stat_tenants_track_options,
PGC_SUSET,
GUC_STANDARD,
NULL, NULL, NULL);

DefineCustomBoolVariable(
"citus.subquery_pushdown",
gettext_noop("Usage of this GUC is highly discouraged, please read the long "
Expand Down
8 changes: 4 additions & 4 deletions src/backend/distributed/sql/citus--11.2-1--11.3-1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ALTER TABLE pg_catalog.pg_dist_transaction REPLICA IDENTITY USING INDEX pg_dist_

#include "udfs/worker_drop_all_shell_tables/11.3-1.sql"
#include "udfs/citus_internal_mark_node_not_synced/11.3-1.sql"
#include "udfs/citus_stats_tenants_local/11.3-1.sql"
#include "udfs/citus_stats_tenants/11.3-1.sql"
#include "udfs/citus_stat_tenants_local/11.3-1.sql"
#include "udfs/citus_stat_tenants/11.3-1.sql"

#include "udfs/citus_stats_tenants_local_reset/11.3-1.sql"
#include "udfs/citus_stats_tenants_reset/11.3-1.sql"
#include "udfs/citus_stat_tenants_local_reset/11.3-1.sql"
#include "udfs/citus_stat_tenants_reset/11.3-1.sql"
12 changes: 6 additions & 6 deletions src/backend/distributed/sql/downgrades/citus--11.3-1--11.2-1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ ALTER TABLE pg_catalog.pg_dist_transaction REPLICA IDENTITY NOTHING;
DROP PROCEDURE pg_catalog.worker_drop_all_shell_tables(bool);
DROP FUNCTION pg_catalog.citus_internal_mark_node_not_synced(int, int);

DROP VIEW pg_catalog.citus_stats_tenants_local;
DROP FUNCTION pg_catalog.citus_stats_tenants_local(boolean);
DROP VIEW pg_catalog.citus_stat_tenants_local;
DROP FUNCTION pg_catalog.citus_stat_tenants_local(boolean);

DROP VIEW pg_catalog.citus_stats_tenants;
DROP FUNCTION pg_catalog.citus_stats_tenants(boolean);
DROP VIEW pg_catalog.citus_stat_tenants;
DROP FUNCTION pg_catalog.citus_stat_tenants(boolean);

DROP FUNCTION pg_catalog.citus_stats_tenants_local_reset();
DROP FUNCTION pg_catalog.citus_stats_tenants_reset();
DROP FUNCTION pg_catalog.citus_stat_tenants_local_reset();
DROP FUNCTION pg_catalog.citus_stat_tenants_reset();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- cts in the query is an abbreviation for citus_stats_tenants
CREATE OR REPLACE FUNCTION pg_catalog.citus_stats_tenants (
-- cts in the query is an abbreviation for citus_stat_tenants
CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants (
return_all_tenants BOOLEAN DEFAULT FALSE,
OUT nodeid INT,
OUT colocation_id INT,
Expand All @@ -18,9 +18,9 @@ BEGIN
array_position(enumvals, 'log') >= array_position(enumvals, setting)
AND setting != 'off'
FROM pg_settings
WHERE name = 'citus.multi_tenant_monitoring_log_level'
WHERE name = 'citus.stat_tenants_log_level'
THEN
RAISE LOG 'Generating citus_stats_tenants';
RAISE LOG 'Generating citus_stat_tenants';
END IF;
RETURN QUERY
SELECT *
Expand All @@ -36,7 +36,7 @@ BEGIN
$$
SELECT
coalesce(to_jsonb (array_agg(cstl.*)), '[]'::jsonb)
FROM citus_stats_tenants_local($$||return_all_tenants||$$) cstl;
FROM citus_stat_tenants_local($$||return_all_tenants||$$) cstl;
$$,
parallel:= TRUE,
give_warning_for_connection_errors:= TRUE)
Expand All @@ -54,11 +54,11 @@ AS (
score BIGINT
)
ORDER BY score DESC
LIMIT CASE WHEN NOT return_all_tenants THEN current_setting('citus.stats_tenants_limit')::BIGINT END;
LIMIT CASE WHEN NOT return_all_tenants THEN current_setting('citus.stat_tenants_limit')::BIGINT END;
END;
$function$;

CREATE OR REPLACE VIEW citus.citus_stats_tenants AS
CREATE OR REPLACE VIEW citus.citus_stat_tenants AS
SELECT
nodeid,
colocation_id,
Expand All @@ -67,12 +67,12 @@ SELECT
read_count_in_last_period,
query_count_in_this_period,
query_count_in_last_period
FROM pg_catalog.citus_stats_tenants(FALSE);
FROM pg_catalog.citus_stat_tenants(FALSE);

ALTER VIEW citus.citus_stats_tenants SET SCHEMA pg_catalog;
ALTER VIEW citus.citus_stat_tenants SET SCHEMA pg_catalog;

REVOKE ALL ON FUNCTION pg_catalog.citus_stats_tenants(BOOLEAN) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION pg_catalog.citus_stats_tenants(BOOLEAN) TO pg_monitor;
REVOKE ALL ON FUNCTION pg_catalog.citus_stat_tenants(BOOLEAN) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION pg_catalog.citus_stat_tenants(BOOLEAN) TO pg_monitor;

REVOKE ALL ON pg_catalog.citus_stats_tenants FROM PUBLIC;
GRANT SELECT ON pg_catalog.citus_stats_tenants TO pg_monitor;
REVOKE ALL ON pg_catalog.citus_stat_tenants FROM PUBLIC;
GRANT SELECT ON pg_catalog.citus_stat_tenants TO pg_monitor;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants_local(
return_all_tenants BOOLEAN DEFAULT FALSE,
OUT colocation_id INT,
OUT tenant_attribute TEXT,
OUT read_count_in_this_period INT,
OUT read_count_in_last_period INT,
OUT query_count_in_this_period INT,
OUT query_count_in_last_period INT,
OUT score BIGINT)
RETURNS SETOF RECORD
LANGUAGE C
AS 'citus', $$citus_stat_tenants_local$$;


CREATE OR REPLACE VIEW citus.citus_stat_tenants_local AS
SELECT
colocation_id,
tenant_attribute,
read_count_in_this_period,
read_count_in_last_period,
query_count_in_this_period,
query_count_in_last_period
FROM pg_catalog.citus_stat_tenants_local()
ORDER BY score DESC;

ALTER VIEW citus.citus_stat_tenants_local SET SCHEMA pg_catalog;

REVOKE ALL ON FUNCTION pg_catalog.citus_stat_tenants_local(BOOLEAN) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION pg_catalog.citus_stat_tenants_local(BOOLEAN) TO pg_monitor;

REVOKE ALL ON pg_catalog.citus_stat_tenants_local FROM PUBLIC;
GRANT SELECT ON pg_catalog.citus_stat_tenants_local TO pg_monitor;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants_local_reset()
RETURNS VOID
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$citus_stat_tenants_local_reset$$;

COMMENT ON FUNCTION pg_catalog.citus_stat_tenants_local_reset()
IS 'resets the local tenant statistics';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants_reset()
RETURNS VOID
LANGUAGE plpgsql
AS $function$
BEGIN
PERFORM run_command_on_all_nodes($$SELECT citus_stat_tenants_local_reset()$$);
END;
$function$;
Loading

0 comments on commit aeb604b

Please sign in to comment.