mirror of https://github.com/citusdata/citus.git
Rename citus stats tenants (#6821)
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`multi-tenant-monitoring-pgbench
parent
2b7482ea0d
commit
14ad3eff54
|
@ -97,6 +97,7 @@
|
|||
#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"
|
||||
|
@ -104,7 +105,6 @@
|
|||
#include "optimizer/optimizer.h"
|
||||
#include "nodes/params.h"
|
||||
#include "utils/snapmgr.h"
|
||||
#include "distributed/utils/attribute.h"
|
||||
|
||||
/* controlled via a GUC */
|
||||
bool EnableLocalExecution = true;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
@ -1990,16 +1990,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."),
|
||||
|
@ -2384,6 +2374,37 @@ RegisterCitusConfigVariables(void)
|
|||
GUC_STANDARD,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
DefineCustomIntVariable(
|
||||
"citus.stat_tenants_limit",
|
||||
gettext_noop("Number of tenants to be shown in citus_stat_tenants."),
|
||||
NULL,
|
||||
&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.stat_tenants_period",
|
||||
gettext_noop("Period in seconds to be used for calculating the tenant "
|
||||
"statistics in citus_stat_tenants."),
|
||||
NULL,
|
||||
&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."),
|
||||
|
@ -2397,27 +2418,6 @@ RegisterCitusConfigVariables(void)
|
|||
GUC_STANDARD,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
DefineCustomIntVariable(
|
||||
"citus.stats_tenants_limit",
|
||||
gettext_noop("Number of tenants to be shown in citus_stat_tenants."),
|
||||
NULL,
|
||||
&CitusStatsTenantsLimit,
|
||||
10, 1, 100,
|
||||
PGC_POSTMASTER,
|
||||
GUC_STANDARD,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
DefineCustomIntVariable(
|
||||
"citus.stats_tenants_period",
|
||||
gettext_noop("Period in seconds to be used for calculating the tenant "
|
||||
"statistics in citus_stat_tenants."),
|
||||
NULL,
|
||||
&CitusStatsTenantsPeriod,
|
||||
60, 1, 1000000000,
|
||||
PGC_USERSET,
|
||||
GUC_STANDARD,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
DefineCustomBoolVariable(
|
||||
"citus.subquery_pushdown",
|
||||
gettext_noop("Usage of this GUC is highly discouraged, please read the long "
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
@ -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 *
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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;
|
|
@ -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,
|
||||
|
@ -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 *
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -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';
|
|
@ -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';
|
|
@ -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$;
|
|
@ -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$;
|
|
@ -1,32 +0,0 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.citus_stats_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_stats_tenants_local$$;
|
||||
|
||||
|
||||
CREATE OR REPLACE VIEW citus.citus_stats_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_stats_tenants_local()
|
||||
ORDER BY score DESC;
|
||||
|
||||
ALTER VIEW citus.citus_stats_tenants_local SET SCHEMA pg_catalog;
|
||||
|
||||
REVOKE ALL ON FUNCTION pg_catalog.citus_stats_tenants_local(BOOLEAN) FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.citus_stats_tenants_local(BOOLEAN) TO pg_monitor;
|
||||
|
||||
REVOKE ALL ON pg_catalog.citus_stats_tenants_local FROM PUBLIC;
|
||||
GRANT SELECT ON pg_catalog.citus_stats_tenants_local TO pg_monitor;
|
|
@ -1,32 +0,0 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.citus_stats_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_stats_tenants_local$$;
|
||||
|
||||
|
||||
CREATE OR REPLACE VIEW citus.citus_stats_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_stats_tenants_local()
|
||||
ORDER BY score DESC;
|
||||
|
||||
ALTER VIEW citus.citus_stats_tenants_local SET SCHEMA pg_catalog;
|
||||
|
||||
REVOKE ALL ON FUNCTION pg_catalog.citus_stats_tenants_local(BOOLEAN) FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.citus_stats_tenants_local(BOOLEAN) TO pg_monitor;
|
||||
|
||||
REVOKE ALL ON pg_catalog.citus_stats_tenants_local FROM PUBLIC;
|
||||
GRANT SELECT ON pg_catalog.citus_stats_tenants_local TO pg_monitor;
|
|
@ -1,7 +0,0 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.citus_stats_tenants_local_reset()
|
||||
RETURNS VOID
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$citus_stats_tenants_local_reset$$;
|
||||
|
||||
COMMENT ON FUNCTION pg_catalog.citus_stats_tenants_local_reset()
|
||||
IS 'resets the local tenant statistics';
|
|
@ -1,7 +0,0 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.citus_stats_tenants_local_reset()
|
||||
RETURNS VOID
|
||||
LANGUAGE C STRICT
|
||||
AS 'MODULE_PATHNAME', $$citus_stats_tenants_local_reset$$;
|
||||
|
||||
COMMENT ON FUNCTION pg_catalog.citus_stats_tenants_local_reset()
|
||||
IS 'resets the local tenant statistics';
|
|
@ -1,8 +0,0 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.citus_stats_tenants_reset()
|
||||
RETURNS VOID
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
PERFORM run_command_on_all_nodes($$SELECT citus_stats_tenants_local_reset()$$);
|
||||
END;
|
||||
$function$;
|
|
@ -1,8 +0,0 @@
|
|||
CREATE OR REPLACE FUNCTION pg_catalog.citus_stats_tenants_reset()
|
||||
RETURNS VOID
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
PERFORM run_command_on_all_nodes($$SELECT citus_stats_tenants_local_reset()$$);
|
||||
END;
|
||||
$function$;
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* citus_stat_tenants.c
|
||||
*
|
||||
* This file contains functions to test citus_stats_tenants.
|
||||
* This file contains functions to test citus_stat_tenants.
|
||||
*
|
||||
* Copyright (c) Citus Data, Inc.
|
||||
*
|
||||
|
@ -12,7 +12,7 @@
|
|||
#include "postgres.h"
|
||||
#include "fmgr.h"
|
||||
|
||||
#include "distributed/utils/attribute.h"
|
||||
#include "distributed/utils/citus_stat_tenants.h"
|
||||
#include "sys/time.h"
|
||||
|
||||
PG_FUNCTION_INFO_V1(sleep_until_next_period);
|
||||
|
@ -27,8 +27,8 @@ sleep_until_next_period(PG_FUNCTION_ARGS)
|
|||
gettimeofday(¤tTime, NULL);
|
||||
|
||||
long int nextPeriodStart = currentTime.tv_sec -
|
||||
(currentTime.tv_sec % CitusStatsTenantsPeriod) +
|
||||
CitusStatsTenantsPeriod;
|
||||
(currentTime.tv_sec % StatTenantsPeriod) +
|
||||
StatTenantsPeriod;
|
||||
|
||||
long int sleepTime = (nextPeriodStart - currentTime.tv_sec) * 1000000 -
|
||||
currentTime.tv_usec + 100000;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* attribute.c
|
||||
* citus_stat_tenants.c
|
||||
* Routines related to the multi tenant monitor.
|
||||
*
|
||||
* Copyright (c) Citus Data, Inc.
|
||||
|
@ -19,6 +19,7 @@
|
|||
#include "distributed/colocation_utils.h"
|
||||
#include "distributed/tuplestore.h"
|
||||
#include "distributed/colocation_utils.h"
|
||||
#include "distributed/utils/citus_stat_tenants.h"
|
||||
#include "executor/execdesc.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/lwlock.h"
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "utils/builtins.h"
|
||||
#include "utils/datetime.h"
|
||||
#include "utils/json.h"
|
||||
#include "distributed/utils/attribute.h"
|
||||
|
||||
|
||||
#include <time.h>
|
||||
|
@ -38,7 +38,7 @@ ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
|
|||
|
||||
#define ATTRIBUTE_PREFIX "/*{\"tId\":"
|
||||
#define ATTRIBUTE_STRING_FORMAT "/*{\"tId\":%s,\"cId\":%d}*/"
|
||||
#define CITUS_STATS_TENANTS_COLUMNS 7
|
||||
#define STAT_TENANTS_COLUMNS 7
|
||||
#define ONE_QUERY_SCORE 1000000000
|
||||
|
||||
/* TODO maybe needs to be a stack */
|
||||
|
@ -70,28 +70,28 @@ static char * ExtractTopComment(const char *inputString);
|
|||
static char * EscapeCommentChars(const char *str);
|
||||
static char * UnescapeCommentChars(const char *str);
|
||||
|
||||
int MultiTenantMonitoringLogLevel = CITUS_LOG_LEVEL_OFF;
|
||||
int CitusStatsTenantsPeriod = (time_t) 60;
|
||||
int CitusStatsTenantsLimit = 10;
|
||||
int StatTenantsLogLevel = CITUS_LOG_LEVEL_OFF;
|
||||
int StatTenantsPeriod = (time_t) 60;
|
||||
int StatTenantsLimit = 10;
|
||||
int StatTenantsTrack = STAT_TENANTS_TRACK_ALL;
|
||||
|
||||
|
||||
PG_FUNCTION_INFO_V1(citus_stats_tenants_local);
|
||||
PG_FUNCTION_INFO_V1(citus_stats_tenants_local_reset);
|
||||
PG_FUNCTION_INFO_V1(citus_stat_tenants_local);
|
||||
PG_FUNCTION_INFO_V1(citus_stat_tenants_local_reset);
|
||||
|
||||
|
||||
/*
|
||||
* citus_stats_tenants_local finds, updates and returns the statistics for tenants.
|
||||
* citus_stat_tenants_local finds, updates and returns the statistics for tenants.
|
||||
*/
|
||||
Datum
|
||||
citus_stats_tenants_local(PG_FUNCTION_ARGS)
|
||||
citus_stat_tenants_local(PG_FUNCTION_ARGS)
|
||||
{
|
||||
CheckCitusVersion(ERROR);
|
||||
|
||||
/*
|
||||
* We keep more than CitusStatsTenantsLimit tenants in our monitor.
|
||||
* We do this to not lose data if a tenant falls out of top CitusStatsTenantsLimit in case they need to return soon.
|
||||
* Normally we return CitusStatsTenantsLimit tenants but if returnAllTenants is true we return all of them.
|
||||
* We keep more than StatTenantsLimit tenants in our monitor.
|
||||
* We do this to not lose data if a tenant falls out of top StatTenantsLimit in case they need to return soon.
|
||||
* Normally we return StatTenantsLimit tenants but if returnAllTenants is true we return all of them.
|
||||
*/
|
||||
bool returnAllTenants = PG_GETARG_BOOL(0);
|
||||
|
||||
|
@ -99,8 +99,8 @@ citus_stats_tenants_local(PG_FUNCTION_ARGS)
|
|||
Tuplestorestate *tupleStore = SetupTuplestore(fcinfo, &tupleDescriptor);
|
||||
TimestampTz monitoringTime = GetCurrentTimestamp();
|
||||
|
||||
Datum values[CITUS_STATS_TENANTS_COLUMNS];
|
||||
bool isNulls[CITUS_STATS_TENANTS_COLUMNS];
|
||||
Datum values[STAT_TENANTS_COLUMNS];
|
||||
bool isNulls[STAT_TENANTS_COLUMNS];
|
||||
|
||||
MultiTenantMonitor *monitor = GetMultiTenantMonitor();
|
||||
|
||||
|
@ -118,7 +118,7 @@ citus_stats_tenants_local(PG_FUNCTION_ARGS)
|
|||
}
|
||||
else
|
||||
{
|
||||
numberOfRowsToReturn = Min(monitor->tenantCount, CitusStatsTenantsLimit);
|
||||
numberOfRowsToReturn = Min(monitor->tenantCount, StatTenantsLimit);
|
||||
}
|
||||
|
||||
for (int tenantIndex = 0; tenantIndex < monitor->tenantCount; tenantIndex++)
|
||||
|
@ -156,11 +156,11 @@ citus_stats_tenants_local(PG_FUNCTION_ARGS)
|
|||
|
||||
|
||||
/*
|
||||
* citus_stats_tenants_local_reset resets monitor for tenant statistics
|
||||
* citus_stat_tenants_local_reset resets monitor for tenant statistics
|
||||
* on the local node.
|
||||
*/
|
||||
Datum
|
||||
citus_stats_tenants_local_reset(PG_FUNCTION_ARGS)
|
||||
citus_stat_tenants_local_reset(PG_FUNCTION_ARGS)
|
||||
{
|
||||
MultiTenantMonitor *monitor = GetMultiTenantMonitor();
|
||||
monitor->tenantCount = 0;
|
||||
|
@ -397,7 +397,7 @@ AttributeMetricsIfApplicable()
|
|||
static void
|
||||
UpdatePeriodsIfNecessary(TenantStats *tenantStats, TimestampTz queryTime)
|
||||
{
|
||||
long long int periodInMicroSeconds = CitusStatsTenantsPeriod * USECS_PER_SEC;
|
||||
long long int periodInMicroSeconds = StatTenantsPeriod * USECS_PER_SEC;
|
||||
TimestampTz periodStart = queryTime - (queryTime % periodInMicroSeconds);
|
||||
|
||||
/*
|
||||
|
@ -438,7 +438,7 @@ UpdatePeriodsIfNecessary(TenantStats *tenantStats, TimestampTz queryTime)
|
|||
static void
|
||||
ReduceScoreIfNecessary(TenantStats *tenantStats, TimestampTz queryTime)
|
||||
{
|
||||
long long int periodInMicroSeconds = CitusStatsTenantsPeriod * USECS_PER_SEC;
|
||||
long long int periodInMicroSeconds = StatTenantsPeriod * USECS_PER_SEC;
|
||||
TimestampTz periodStart = queryTime - (queryTime % periodInMicroSeconds);
|
||||
|
||||
/*
|
||||
|
@ -475,7 +475,7 @@ ReduceScoreIfNecessary(TenantStats *tenantStats, TimestampTz queryTime)
|
|||
|
||||
/*
|
||||
* EvictTenantsIfNecessary sorts and evicts the tenants if the tenant count is more than or
|
||||
* equal to 3 * CitusStatsTenantsLimit.
|
||||
* equal to 3 * StatTenantsLimit.
|
||||
*/
|
||||
static void
|
||||
EvictTenantsIfNecessary(TimestampTz queryTime)
|
||||
|
@ -483,12 +483,12 @@ EvictTenantsIfNecessary(TimestampTz queryTime)
|
|||
MultiTenantMonitor *monitor = GetMultiTenantMonitor();
|
||||
|
||||
/*
|
||||
* We keep up to CitusStatsTenantsLimit * 3 tenants instead of CitusStatsTenantsLimit,
|
||||
* so we don't lose data immediately after a tenant is out of top CitusStatsTenantsLimit
|
||||
* We keep up to StatTenantsLimit * 3 tenants instead of StatTenantsLimit,
|
||||
* so we don't lose data immediately after a tenant is out of top StatTenantsLimit
|
||||
*
|
||||
* Every time tenant count hits CitusStatsTenantsLimit * 3, we reduce it back to CitusStatsTenantsLimit * 2.
|
||||
* Every time tenant count hits StatTenantsLimit * 3, we reduce it back to StatTenantsLimit * 2.
|
||||
*/
|
||||
if (monitor->tenantCount >= CitusStatsTenantsLimit * 3)
|
||||
if (monitor->tenantCount >= StatTenantsLimit * 3)
|
||||
{
|
||||
for (int tenantIndex = 0; tenantIndex < monitor->tenantCount; tenantIndex++)
|
||||
{
|
||||
|
@ -496,7 +496,7 @@ EvictTenantsIfNecessary(TimestampTz queryTime)
|
|||
}
|
||||
SafeQsort(monitor->tenants, monitor->tenantCount, sizeof(TenantStats),
|
||||
CompareTenantScore);
|
||||
monitor->tenantCount = CitusStatsTenantsLimit * 2;
|
||||
monitor->tenantCount = StatTenantsLimit * 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,7 +623,7 @@ static int
|
|||
CreateTenantStats(MultiTenantMonitor *monitor, TimestampTz queryTime)
|
||||
{
|
||||
/*
|
||||
* If the tenant count reached 3 * CitusStatsTenantsLimit, we evict the tenants
|
||||
* If the tenant count reached 3 * StatTenantsLimit, we evict the tenants
|
||||
* with the lowest score.
|
||||
*/
|
||||
EvictTenantsIfNecessary(queryTime);
|
||||
|
@ -672,13 +672,13 @@ FindTenantStats(MultiTenantMonitor *monitor)
|
|||
|
||||
/*
|
||||
* MultiTenantMonitorshmemSize calculates the size of the multi tenant monitor using
|
||||
* CitusStatsTenantsLimit parameter.
|
||||
* StatTenantsLimit parameter.
|
||||
*/
|
||||
static size_t
|
||||
MultiTenantMonitorshmemSize(void)
|
||||
{
|
||||
Size size = sizeof(MultiTenantMonitor);
|
||||
size = add_size(size, mul_size(sizeof(TenantStats), CitusStatsTenantsLimit * 3));
|
||||
size = add_size(size, mul_size(sizeof(TenantStats), StatTenantsLimit * 3));
|
||||
|
||||
return size;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* attribute.h
|
||||
* citus_stat_tenants.h
|
||||
* Routines related to the multi tenant monitor.
|
||||
*
|
||||
* Copyright (c) Citus Data, Inc.
|
||||
|
@ -82,7 +82,7 @@ typedef struct MultiTenantMonitor
|
|||
/*
|
||||
* tenantCount is the number of items in the tenants array.
|
||||
* The total length of tenants array is set up at CreateSharedMemoryForMultiTenantMonitor
|
||||
* and is 3 * citus.stats_tenants_limit
|
||||
* and is 3 * citus.stat_tenants_limit
|
||||
*/
|
||||
int tenantCount;
|
||||
TenantStats tenants[FLEXIBLE_ARRAY_MEMBER];
|
||||
|
@ -103,9 +103,9 @@ extern void AttributeTask(char *tenantId, int colocationGroupId, CmdType command
|
|||
|
||||
extern ExecutorEnd_hook_type prev_ExecutorEnd;
|
||||
|
||||
extern int MultiTenantMonitoringLogLevel;
|
||||
extern int CitusStatsTenantsPeriod;
|
||||
extern int CitusStatsTenantsLimit;
|
||||
extern int StatTenantsLogLevel;
|
||||
extern int StatTenantsPeriod;
|
||||
extern int StatTenantsLimit;
|
||||
extern int StatTenantsTrack;
|
||||
|
||||
#endif /*CITUS_ATTRIBUTE_H */
|
|
@ -1,19 +1,19 @@
|
|||
CREATE SCHEMA citus_stats_tenants;
|
||||
SET search_path TO citus_stats_tenants;
|
||||
CREATE SCHEMA citus_stat_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
SET citus.next_shard_id TO 5797500;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
CREATE OR REPLACE FUNCTION pg_catalog.sleep_until_next_period()
|
||||
RETURNS VOID
|
||||
LANGUAGE C
|
||||
AS 'citus', $$sleep_until_next_period$$;
|
||||
SELECT citus_stats_tenants_reset();
|
||||
citus_stats_tenants_reset
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- set period to a high number to prevent stats from being reset
|
||||
SELECT result FROM run_command_on_all_nodes('ALTER SYSTEM SET citus.stats_tenants_period TO 1000000000');
|
||||
SELECT result FROM run_command_on_all_nodes('ALTER SYSTEM SET citus.stat_tenants_period TO 1000000000');
|
||||
result
|
||||
---------------------------------------------------------------------
|
||||
ALTER SYSTEM
|
||||
|
@ -62,7 +62,7 @@ INSERT INTO dist_tbl VALUES (2, 'abcd');
|
|||
UPDATE dist_tbl SET b = a + 1 WHERE a = 3;
|
||||
UPDATE dist_tbl SET b = a + 1 WHERE a = 4;
|
||||
DELETE FROM dist_tbl WHERE a = 5;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants(true) ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants(true) ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
1 | 0 | 0 | 1 | 0
|
||||
|
@ -72,8 +72,8 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
5 | 0 | 0 | 1 | 0
|
||||
(5 rows)
|
||||
|
||||
SELECT citus_stats_tenants_reset();
|
||||
citus_stats_tenants_reset
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
@ -92,7 +92,7 @@ SELECT count(*)>=0 FROM ref_tbl WHERE a = 1;
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants(true) ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants(true) ORDER BY tenant_attribute;
|
||||
tenant_attribute | query_count_in_this_period
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
@ -110,7 +110,7 @@ SELECT count(*)>=0 FROM dist_tbl JOIN dist_tbl_2 ON dist_tbl.a = dist_tbl_2.a WH
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants(true) WHERE tenant_attribute = '1';
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants(true) WHERE tenant_attribute = '1';
|
||||
tenant_attribute | query_count_in_this_period
|
||||
---------------------------------------------------------------------
|
||||
1 | 2
|
||||
|
@ -143,7 +143,7 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'abcd';
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stats_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stat_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
tenant_attribute | query_count_in_this_period | score
|
||||
---------------------------------------------------------------------
|
||||
2 | 1 | 1000000000
|
||||
|
@ -176,7 +176,7 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'cdef';
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stats_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stat_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
tenant_attribute | query_count_in_this_period | score
|
||||
---------------------------------------------------------------------
|
||||
abcd | 3 | 3000000000
|
||||
|
@ -205,7 +205,7 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'defg';
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stats_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stat_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
tenant_attribute | query_count_in_this_period | score
|
||||
---------------------------------------------------------------------
|
||||
abcd | 3 | 3000000000
|
||||
|
@ -218,8 +218,8 @@ SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stats_tena
|
|||
(7 rows)
|
||||
|
||||
-- test period passing
|
||||
SELECT citus_stats_tenants_reset();
|
||||
citus_stats_tenants_reset
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
@ -232,7 +232,7 @@ SELECT count(*)>=0 FROM dist_tbl WHERE a = 1;
|
|||
|
||||
INSERT INTO dist_tbl VALUES (5, 'abcd');
|
||||
\c - - - :worker_1_port
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
1 | 1 | 0 | 1 | 0
|
||||
|
@ -240,14 +240,14 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
(2 rows)
|
||||
|
||||
-- simulate passing the period
|
||||
SET citus.stats_tenants_period TO 2;
|
||||
SET citus.stat_tenants_period TO 2;
|
||||
SELECT sleep_until_next_period();
|
||||
sleep_until_next_period
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
1 | 0 | 1 | 0 | 1
|
||||
|
@ -255,50 +255,50 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
(2 rows)
|
||||
|
||||
\c - - - :master_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
-- test logs
|
||||
SET client_min_messages TO LOG;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SET citus.multi_tenant_monitoring_log_level TO ERROR;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SET citus.stat_tenants_log_level TO ERROR;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SET citus.multi_tenant_monitoring_log_level TO OFF;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SET citus.stat_tenants_log_level TO OFF;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SET citus.multi_tenant_monitoring_log_level TO LOG;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
LOG: Generating citus_stats_tenants
|
||||
CONTEXT: PL/pgSQL function citus_stats_tenants(boolean) line XX at RAISE
|
||||
SET citus.stat_tenants_log_level TO LOG;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
LOG: Generating citus_stat_tenants
|
||||
CONTEXT: PL/pgSQL function citus_stat_tenants(boolean) line XX at RAISE
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SET citus.multi_tenant_monitoring_log_level TO DEBUG;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
LOG: Generating citus_stats_tenants
|
||||
CONTEXT: PL/pgSQL function citus_stats_tenants(boolean) line XX at RAISE
|
||||
SET citus.stat_tenants_log_level TO DEBUG;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
LOG: Generating citus_stat_tenants
|
||||
CONTEXT: PL/pgSQL function citus_stat_tenants(boolean) line XX at RAISE
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
RESET client_min_messages;
|
||||
SELECT citus_stats_tenants_reset();
|
||||
citus_stats_tenants_reset
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
@ -312,13 +312,13 @@ SELECT count(*)>=0 FROM dist_tbl WHERE a = 1;
|
|||
(1 row)
|
||||
|
||||
INSERT INTO dist_tbl VALUES (1, 1);
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
tenant_attribute | query_count_in_this_period
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SET citus.stat_tenants_track TO "ALL";
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
tenant_attribute | query_count_in_this_period
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
@ -330,15 +330,15 @@ SELECT count(*)>=0 FROM dist_tbl WHERE a = 1;
|
|||
(1 row)
|
||||
|
||||
INSERT INTO dist_tbl VALUES (1, 1);
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
tenant_attribute | query_count_in_this_period
|
||||
---------------------------------------------------------------------
|
||||
1 | 2
|
||||
(1 row)
|
||||
|
||||
-- test special and multibyte characters in tenant attribute
|
||||
SELECT citus_stats_tenants_reset();
|
||||
citus_stats_tenants_reset
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
@ -405,7 +405,7 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = U&'\0061\0308bc';
|
|||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
/*bcde | 1 | 0 | 1 | 0
|
||||
|
@ -421,8 +421,8 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
(10 rows)
|
||||
|
||||
\c - - - :worker_2_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
/*bcde | 1 | 0 | 1 | 0
|
||||
|
@ -437,8 +437,8 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
bcde*/ | 1 | 0 | 1 | 0
|
||||
(10 rows)
|
||||
|
||||
SELECT citus_stats_tenants_reset();
|
||||
citus_stats_tenants_reset
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
@ -469,7 +469,7 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde*';
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
/b*c/de | 1 | 0 | 1 | 0
|
||||
|
@ -552,7 +552,7 @@ EXECUTE dist_tbl_text_select_plan('bcde*');
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
/b*c/de | 4 | 0 | 4 | 0
|
||||
|
@ -562,7 +562,7 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
(4 rows)
|
||||
|
||||
\c - - - :master_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
PREPARE dist_tbl_text_select_plan (text) AS SELECT count(*)>=0 FROM dist_tbl_text WHERE a = $1;
|
||||
EXECUTE dist_tbl_text_select_plan('/b*c/de');
|
||||
?column?
|
||||
|
@ -637,8 +637,8 @@ EXECUTE dist_tbl_text_select_plan('bcde*');
|
|||
(1 row)
|
||||
|
||||
\c - - - :worker_2_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
/b*c/de | 7 | 0 | 7 | 0
|
||||
|
@ -648,9 +648,9 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
(4 rows)
|
||||
|
||||
\c - - - :master_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SELECT citus_stats_tenants_reset();
|
||||
citus_stats_tenants_reset
|
||||
SET search_path TO citus_stat_tenants;
|
||||
SELECT citus_stat_tenants_reset();
|
||||
citus_stat_tenants_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
@ -661,7 +661,7 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'thisisaverylooooooooooooooooooo
|
|||
t
|
||||
(1 row)
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
|
||||
---------------------------------------------------------------------
|
||||
thisisaverylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo | 1 | 0 | 1 | 0
|
||||
|
@ -670,36 +670,36 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
|
|||
-- test role permissions
|
||||
CREATE ROLE stats_non_superuser WITH LOGIN;
|
||||
SET ROLE stats_non_superuser;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
ERROR: permission denied for view citus_stats_tenants
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local;
|
||||
ERROR: permission denied for view citus_stats_tenants_local
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants();
|
||||
ERROR: permission denied for function citus_stats_tenants
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local();
|
||||
ERROR: permission denied for function citus_stats_tenants_local
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
ERROR: permission denied for view citus_stat_tenants
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local;
|
||||
ERROR: permission denied for view citus_stat_tenants_local
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants();
|
||||
ERROR: permission denied for function citus_stat_tenants
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local();
|
||||
ERROR: permission denied for function citus_stat_tenants_local
|
||||
RESET ROLE;
|
||||
GRANT pg_monitor TO stats_non_superuser;
|
||||
SET ROLE stats_non_superuser;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants();
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants();
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local();
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local();
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
|
@ -708,4 +708,4 @@ SELECT count(*)>=0 FROM citus_stats_tenants_local();
|
|||
RESET ROLE;
|
||||
DROP ROLE stats_non_superuser;
|
||||
SET client_min_messages TO ERROR;
|
||||
DROP SCHEMA citus_stats_tenants CASCADE;
|
||||
DROP SCHEMA citus_stat_tenants CASCADE;
|
|
@ -1366,14 +1366,14 @@ SELECT * FROM multi_extension.print_extension_changes();
|
|||
| function citus_internal_mark_node_not_synced(integer,integer) void
|
||||
| function citus_internal_start_replication_origin_tracking() void
|
||||
| function citus_internal_stop_replication_origin_tracking() void
|
||||
| function citus_stats_tenants(boolean) SETOF record
|
||||
| function citus_stats_tenants_local(boolean) SETOF record
|
||||
| function citus_stats_tenants_local_reset() void
|
||||
| function citus_stats_tenants_reset() void
|
||||
| function citus_stat_tenants(boolean) SETOF record
|
||||
| function citus_stat_tenants_local(boolean) SETOF record
|
||||
| function citus_stat_tenants_local_reset() void
|
||||
| function citus_stat_tenants_reset() void
|
||||
| function worker_adjust_identity_column_seq_ranges(regclass) void
|
||||
| function worker_drop_all_shell_tables(boolean)
|
||||
| view citus_stats_tenants
|
||||
| view citus_stats_tenants_local
|
||||
| view citus_stat_tenants
|
||||
| view citus_stat_tenants_local
|
||||
(12 rows)
|
||||
|
||||
DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff;
|
||||
|
|
|
@ -21,8 +21,8 @@ ORDER BY 1;
|
|||
---------------------------------------------------------------------
|
||||
pg_dist_authinfo
|
||||
pg_dist_clock_logical_seq
|
||||
citus_stats_tenants_local
|
||||
citus_stats_tenants
|
||||
citus_stat_tenants_local
|
||||
citus_stat_tenants
|
||||
(4 rows)
|
||||
|
||||
RESET role;
|
||||
|
|
|
@ -125,10 +125,10 @@ ORDER BY 1;
|
|||
function citus_stat_activity()
|
||||
function citus_stat_statements()
|
||||
function citus_stat_statements_reset()
|
||||
function citus_stats_tenants(boolean)
|
||||
function citus_stats_tenants_local(boolean)
|
||||
function citus_stats_tenants_local_reset()
|
||||
function citus_stats_tenants_reset()
|
||||
function citus_stat_tenants(boolean)
|
||||
function citus_stat_tenants_local(boolean)
|
||||
function citus_stat_tenants_local_reset()
|
||||
function citus_stat_tenants_reset()
|
||||
function citus_table_is_visible(oid)
|
||||
function citus_table_size(regclass)
|
||||
function citus_task_wait(bigint,citus_task_status)
|
||||
|
@ -326,8 +326,8 @@ ORDER BY 1;
|
|||
view citus_shards_on_worker
|
||||
view citus_stat_activity
|
||||
view citus_stat_statements
|
||||
view citus_stats_tenants
|
||||
view citus_stats_tenants_local
|
||||
view citus_stat_tenants
|
||||
view citus_stat_tenants_local
|
||||
view pg_dist_shard_placement
|
||||
view time_partitions
|
||||
(322 rows)
|
||||
|
|
|
@ -105,7 +105,7 @@ test: citus_update_table_statistics
|
|||
# ----------
|
||||
# Test for tenant statistics
|
||||
# ----------
|
||||
test: citus_stats_tenants
|
||||
test: citus_stat_tenants
|
||||
|
||||
# ----------
|
||||
# Parallel TPC-H tests to check our distributed execution behavior
|
||||
|
|
|
@ -489,7 +489,7 @@ push(@pgOptions, "citus.enable_manual_changes_to_shards=on");
|
|||
push(@pgOptions, "citus.allow_unsafe_locks_from_workers=on");
|
||||
push(@pgOptions, "citus.stat_statements_track = 'all'");
|
||||
push(@pgOptions, "citus.enable_change_data_capture=on");
|
||||
push(@pgOptions, "citus.stats_tenants_limit = 10");
|
||||
push(@pgOptions, "citus.stat_tenants_limit = 10");
|
||||
|
||||
# Some tests look at shards in pg_class, make sure we can usually see them:
|
||||
push(@pgOptions, "citus.show_shards_for_app_name_prefixes='pg_regress'");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
CREATE SCHEMA citus_stats_tenants;
|
||||
SET search_path TO citus_stats_tenants;
|
||||
CREATE SCHEMA citus_stat_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
SET citus.next_shard_id TO 5797500;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
|
||||
|
@ -8,10 +8,10 @@ RETURNS VOID
|
|||
LANGUAGE C
|
||||
AS 'citus', $$sleep_until_next_period$$;
|
||||
|
||||
SELECT citus_stats_tenants_reset();
|
||||
SELECT citus_stat_tenants_reset();
|
||||
|
||||
-- set period to a high number to prevent stats from being reset
|
||||
SELECT result FROM run_command_on_all_nodes('ALTER SYSTEM SET citus.stats_tenants_period TO 1000000000');
|
||||
SELECT result FROM run_command_on_all_nodes('ALTER SYSTEM SET citus.stat_tenants_period TO 1000000000');
|
||||
SELECT result FROM run_command_on_all_nodes('SELECT pg_reload_conf()');
|
||||
|
||||
CREATE TABLE dist_tbl (a INT, b TEXT);
|
||||
|
@ -32,9 +32,9 @@ UPDATE dist_tbl SET b = a + 1 WHERE a = 3;
|
|||
UPDATE dist_tbl SET b = a + 1 WHERE a = 4;
|
||||
DELETE FROM dist_tbl WHERE a = 5;
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants(true) ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants(true) ORDER BY tenant_attribute;
|
||||
|
||||
SELECT citus_stats_tenants_reset();
|
||||
SELECT citus_stat_tenants_reset();
|
||||
|
||||
-- queries with multiple tenants should not be counted
|
||||
SELECT count(*)>=0 FROM dist_tbl WHERE a IN (1, 5);
|
||||
|
@ -42,13 +42,13 @@ SELECT count(*)>=0 FROM dist_tbl WHERE a IN (1, 5);
|
|||
-- queries with reference tables should not be counted
|
||||
SELECT count(*)>=0 FROM ref_tbl WHERE a = 1;
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants(true) ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants(true) ORDER BY tenant_attribute;
|
||||
|
||||
-- queries with multiple tables but one tenant should be counted
|
||||
SELECT count(*)>=0 FROM dist_tbl, dist_tbl_2 WHERE dist_tbl.a = 1 AND dist_tbl_2.a = 1;
|
||||
SELECT count(*)>=0 FROM dist_tbl JOIN dist_tbl_2 ON dist_tbl.a = dist_tbl_2.a WHERE dist_tbl.a = 1;
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants(true) WHERE tenant_attribute = '1';
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants(true) WHERE tenant_attribute = '1';
|
||||
|
||||
-- test scoring
|
||||
-- all of these distribution column values are from second worker
|
||||
|
@ -59,72 +59,72 @@ SELECT count(*)>=0 FROM dist_tbl WHERE a = 3;
|
|||
SELECT count(*)>=0 FROM dist_tbl WHERE a = 4;
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'abcd';
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stats_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stat_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'abcd';
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'abcd';
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde';
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'cdef';
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stats_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stat_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde';
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde';
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'defg';
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stats_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
SELECT tenant_attribute, query_count_in_this_period, score FROM citus_stat_tenants(true) WHERE nodeid = :worker_2_nodeid ORDER BY score DESC, tenant_attribute;
|
||||
|
||||
-- test period passing
|
||||
SELECT citus_stats_tenants_reset();
|
||||
SELECT citus_stat_tenants_reset();
|
||||
|
||||
SELECT count(*)>=0 FROM dist_tbl WHERE a = 1;
|
||||
INSERT INTO dist_tbl VALUES (5, 'abcd');
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
|
||||
-- simulate passing the period
|
||||
SET citus.stats_tenants_period TO 2;
|
||||
SET citus.stat_tenants_period TO 2;
|
||||
SELECT sleep_until_next_period();
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
|
||||
\c - - - :master_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
|
||||
-- test logs
|
||||
SET client_min_messages TO LOG;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SET citus.multi_tenant_monitoring_log_level TO ERROR;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SET citus.multi_tenant_monitoring_log_level TO OFF;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SET citus.multi_tenant_monitoring_log_level TO LOG;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SET citus.multi_tenant_monitoring_log_level TO DEBUG;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
SET citus.stat_tenants_log_level TO ERROR;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
SET citus.stat_tenants_log_level TO OFF;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
SET citus.stat_tenants_log_level TO LOG;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
SET citus.stat_tenants_log_level TO DEBUG;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
RESET client_min_messages;
|
||||
|
||||
SELECT citus_stats_tenants_reset();
|
||||
SELECT citus_stat_tenants_reset();
|
||||
|
||||
-- test turning monitoring on/off
|
||||
SET citus.stat_tenants_track TO "NONE";
|
||||
SELECT count(*)>=0 FROM dist_tbl WHERE a = 1;
|
||||
INSERT INTO dist_tbl VALUES (1, 1);
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
|
||||
SET citus.stat_tenants_track TO "ALL";
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
|
||||
SELECT count(*)>=0 FROM dist_tbl WHERE a = 1;
|
||||
INSERT INTO dist_tbl VALUES (1, 1);
|
||||
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stats_tenants;
|
||||
SELECT tenant_attribute, query_count_in_this_period FROM citus_stat_tenants;
|
||||
|
||||
-- test special and multibyte characters in tenant attribute
|
||||
SELECT citus_stats_tenants_reset();
|
||||
SELECT citus_stat_tenants_reset();
|
||||
TRUNCATE TABLE dist_tbl_text;
|
||||
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = '/bcde';
|
||||
|
@ -139,13 +139,13 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde*/';
|
|||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = U&'\0061\0308bc';
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
\c - - - :worker_2_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
|
||||
SELECT citus_stats_tenants_reset();
|
||||
SELECT citus_stat_tenants_reset();
|
||||
|
||||
-- test local queries
|
||||
-- all of these distribution column values are from second worker
|
||||
|
@ -155,7 +155,7 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = '/bcde';
|
|||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = U&'\0061\0308bc';
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde*';
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
|
||||
-- test local cached queries & prepared statements
|
||||
|
||||
|
@ -174,10 +174,10 @@ EXECUTE dist_tbl_text_select_plan('/bcde');
|
|||
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
|
||||
EXECUTE dist_tbl_text_select_plan('bcde*');
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants_local ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants_local ORDER BY tenant_attribute;
|
||||
|
||||
\c - - - :master_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
|
||||
PREPARE dist_tbl_text_select_plan (text) AS SELECT count(*)>=0 FROM dist_tbl_text WHERE a = $1;
|
||||
|
||||
|
@ -195,38 +195,38 @@ EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
|
|||
EXECUTE dist_tbl_text_select_plan('bcde*');
|
||||
|
||||
\c - - - :worker_2_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
|
||||
\c - - - :master_port
|
||||
SET search_path TO citus_stats_tenants;
|
||||
SET search_path TO citus_stat_tenants;
|
||||
|
||||
SELECT citus_stats_tenants_reset();
|
||||
SELECT citus_stat_tenants_reset();
|
||||
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'thisisaveryloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongname';
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
|
||||
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stat_tenants ORDER BY tenant_attribute;
|
||||
|
||||
-- test role permissions
|
||||
CREATE ROLE stats_non_superuser WITH LOGIN;
|
||||
SET ROLE stats_non_superuser;
|
||||
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants();
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local();
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants();
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local();
|
||||
|
||||
RESET ROLE;
|
||||
GRANT pg_monitor TO stats_non_superuser;
|
||||
|
||||
SET ROLE stats_non_superuser;
|
||||
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local;
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants();
|
||||
SELECT count(*)>=0 FROM citus_stats_tenants_local();
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local;
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants();
|
||||
SELECT count(*)>=0 FROM citus_stat_tenants_local();
|
||||
|
||||
RESET ROLE;
|
||||
DROP ROLE stats_non_superuser;
|
||||
|
||||
SET client_min_messages TO ERROR;
|
||||
DROP SCHEMA citus_stats_tenants CASCADE;
|
||||
DROP SCHEMA citus_stat_tenants CASCADE;
|
Loading…
Reference in New Issue