From 1910434174234ccdf5e30291453eb5ebda687b9b Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 30 Aug 2023 20:48:26 +0200 Subject: [PATCH 01/23] Remove CurrentStatusInfo --- src/Common/StatusInfo.cpp | 57 -------------------------- src/Common/StatusInfo.h | 39 ------------------ src/Interpreters/ExternalLoader.cpp | 10 ----- src/Server/PrometheusMetricsWriter.cpp | 38 ----------------- src/Server/PrometheusMetricsWriter.h | 2 - 5 files changed, 146 deletions(-) delete mode 100644 src/Common/StatusInfo.cpp delete mode 100644 src/Common/StatusInfo.h diff --git a/src/Common/StatusInfo.cpp b/src/Common/StatusInfo.cpp deleted file mode 100644 index 1f9ddfaf4b9..00000000000 --- a/src/Common/StatusInfo.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -/// Available status. Add something here as you wish. -#define APPLY_FOR_STATUS(M) \ - M(DictionaryStatus, "Dictionary Status.", DB::getStatusEnumAllPossibleValues()) \ - - -namespace CurrentStatusInfo -{ - #define M(NAME, DOCUMENTATION, ENUM) extern const Status NAME = Status(__COUNTER__); - APPLY_FOR_STATUS(M) - #undef M - constexpr Status END = Status(__COUNTER__); - - std::mutex locks[END] {}; - std::unordered_map values[END] {}; - - const char * getName(Status event) - { - static const char * strings[] = - { - #define M(NAME, DOCUMENTATION, ENUM) #NAME, - APPLY_FOR_STATUS(M) - #undef M - }; - - return strings[event]; - } - - const char * getDocumentation(Status event) - { - static const char * strings[] = - { - #define M(NAME, DOCUMENTATION, ENUM) #DOCUMENTATION, - APPLY_FOR_STATUS(M) - #undef M - }; - - return strings[event]; - } - - const std::vector> & getAllPossibleValues(Status event) - { - static const std::vector> enum_values [] = - { - #define M(NAME, DOCUMENTATION, ENUM) ENUM, - APPLY_FOR_STATUS(M) - #undef M - }; - return enum_values[event]; - } - - Status end() { return END; } -} - -#undef APPLY_FOR_STATUS diff --git a/src/Common/StatusInfo.h b/src/Common/StatusInfo.h deleted file mode 100644 index 91e6d4d3b85..00000000000 --- a/src/Common/StatusInfo.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace CurrentStatusInfo -{ - using Status = StrongTypedef; - using Key = std::string; - - const char * getName(Status event); - const char * getDocumentation(Status event); - const std::vector> & getAllPossibleValues(Status event); - - extern std::unordered_map values[]; - extern std::mutex locks[]; - - Status end(); - - inline void set(Status status, Key key, Int8 value) - { - std::lock_guard lock(locks[status]); - values[status][key] = value; - } - - inline void unset(Status status, Key key) - { - std::lock_guard lock(locks[status]); - values[status].erase(key); - } -} diff --git a/src/Interpreters/ExternalLoader.cpp b/src/Interpreters/ExternalLoader.cpp index 5dee750889c..56d480d8735 100644 --- a/src/Interpreters/ExternalLoader.cpp +++ b/src/Interpreters/ExternalLoader.cpp @@ -1,7 +1,6 @@ #include "ExternalLoader.h" #include -#include #include #include #include @@ -9,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -18,12 +16,6 @@ #include -namespace CurrentStatusInfo -{ - extern const Status DictionaryStatus; -} - - namespace DB { namespace ErrorCodes @@ -1145,7 +1137,6 @@ private: if (info && (info->loading_id == loading_id)) { info->loading_id = info->state_id; - CurrentStatusInfo::set(CurrentStatusInfo::DictionaryStatus, name, static_cast(info->status())); } min_id_to_finish_loading_dependencies.erase(std::this_thread::get_id()); @@ -1307,7 +1298,6 @@ scope_guard ExternalLoader::addConfigRepository(std::unique_ptrremoveConfigRepository(ptr); - CurrentStatusInfo::unset(CurrentStatusInfo::DictionaryStatus, name); reloadConfig(name); }; } diff --git a/src/Server/PrometheusMetricsWriter.cpp b/src/Server/PrometheusMetricsWriter.cpp index 2331e455225..a7d90b9985c 100644 --- a/src/Server/PrometheusMetricsWriter.cpp +++ b/src/Server/PrometheusMetricsWriter.cpp @@ -1,7 +1,6 @@ #include "PrometheusMetricsWriter.h" #include -#include #include /// TODO: this library is harmful. #include @@ -51,7 +50,6 @@ PrometheusMetricsWriter::PrometheusMetricsWriter( , send_events(config.getBool(config_name + ".events", true)) , send_metrics(config.getBool(config_name + ".metrics", true)) , send_asynchronous_metrics(config.getBool(config_name + ".asynchronous_metrics", true)) - , send_status_info(config.getBool(config_name + ".status_info", true)) { } @@ -120,42 +118,6 @@ void PrometheusMetricsWriter::write(WriteBuffer & wb) const writeOutLine(wb, key, value.value); } } - - if (send_status_info) - { - for (size_t i = 0, end = CurrentStatusInfo::end(); i < end; ++i) - { - std::lock_guard lock(CurrentStatusInfo::locks[static_cast(i)]); - std::string metric_name{CurrentStatusInfo::getName(static_cast(i))}; - std::string metric_doc{CurrentStatusInfo::getDocumentation(static_cast(i))}; - - convertHelpToSingleLine(metric_doc); - - if (!replaceInvalidChars(metric_name)) - continue; - std::string key{current_status_prefix + metric_name}; - - writeOutLine(wb, "# HELP", key, metric_doc); - writeOutLine(wb, "# TYPE", key, "gauge"); - - for (const auto & value: CurrentStatusInfo::values[i]) - { - for (const auto & enum_value: CurrentStatusInfo::getAllPossibleValues(static_cast(i))) - { - DB::writeText(key, wb); - DB::writeChar('{', wb); - DB::writeText(key, wb); - DB::writeChar('=', wb); - writeDoubleQuotedString(enum_value.first, wb); - DB::writeText(",name=", wb); - writeDoubleQuotedString(value.first, wb); - DB::writeText("} ", wb); - DB::writeText(value.second == enum_value.second, wb); - DB::writeChar('\n', wb); - } - } - } - } } } diff --git a/src/Server/PrometheusMetricsWriter.h b/src/Server/PrometheusMetricsWriter.h index b4f6ab57def..b05eeaf0a3a 100644 --- a/src/Server/PrometheusMetricsWriter.h +++ b/src/Server/PrometheusMetricsWriter.h @@ -27,12 +27,10 @@ private: const bool send_events; const bool send_metrics; const bool send_asynchronous_metrics; - const bool send_status_info; static inline constexpr auto profile_events_prefix = "ClickHouseProfileEvents_"; static inline constexpr auto current_metrics_prefix = "ClickHouseMetrics_"; static inline constexpr auto asynchronous_metrics_prefix = "ClickHouseAsyncMetrics_"; - static inline constexpr auto current_status_prefix = "ClickHouseStatusInfo_"; }; } From 9d6dc1067f172187a739e0939e23acad0e631dc1 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 30 Aug 2023 20:49:02 +0200 Subject: [PATCH 02/23] Remove CurrentStatusInfo --- ...HouseStatusInfo_DictionaryStatus.reference | 18 --------- ...s_ClickHouseStatusInfo_DictionaryStatus.sh | 38 ------------------- 2 files changed, 56 deletions(-) delete mode 100644 tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.reference delete mode 100755 tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.sh diff --git a/tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.reference b/tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.reference deleted file mode 100644 index 50c91c3fa0c..00000000000 --- a/tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.reference +++ /dev/null @@ -1,18 +0,0 @@ -status before reload -status after reload -NOT_LOADED 0 -LOADED 0 -FAILED 1 -LOADING 0 -FAILED_AND_RELOADING 0 -LOADED_AND_RELOADING 0 -NOT_EXIST 0 -status after reload, table exists -NOT_LOADED 0 -LOADED 1 -FAILED 0 -LOADING 0 -FAILED_AND_RELOADING 0 -LOADED_AND_RELOADING 0 -NOT_EXIST 0 -status after drop diff --git a/tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.sh b/tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.sh deleted file mode 100755 index 65025858e20..00000000000 --- a/tests/queries/0_stateless/02390_prometheus_ClickHouseStatusInfo_DictionaryStatus.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# Tags: no-ordinary-database - -CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# shellcheck source=../shell_config.sh -. "$CUR_DIR"/../shell_config.sh - -function get_dictionary_status() -{ - local name=$1 && shift - $CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL_PROMETHEUS" | { - awk -F'[{}=," ]' -vname="$name" '/ClickHouseStatusInfo_DictionaryStatus{/ && $(NF-3) == name { print $4, $NF }' - } -} - -$CLICKHOUSE_CLIENT -q "CREATE DICTIONARY dict (key Int, value String) PRIMARY KEY key SOURCE(CLICKHOUSE(TABLE data)) LAYOUT(HASHED()) LIFETIME(0)" -uuid="$($CLICKHOUSE_CLIENT -q "SELECT uuid FROM system.dictionaries WHERE database = '$CLICKHOUSE_DATABASE' AND name = 'dict'")" - -echo 'status before reload' -get_dictionary_status "$uuid" - -# source table does not exists -# NOTE: when dictionary does not exist it produce BAD_ARGUMENTS error, so using UNKNOWN_TABLE is safe -$CLICKHOUSE_CLIENT -n -q "SYSTEM RELOAD DICTIONARY dict -- { serverError UNKNOWN_TABLE }" -echo 'status after reload' -get_dictionary_status "$uuid" - -# create source -$CLICKHOUSE_CLIENT -q "CREATE TABLE data (key Int, value String) Engine=Null" -$CLICKHOUSE_CLIENT -q "SYSTEM RELOAD DICTIONARY dict" -echo 'status after reload, table exists' -get_dictionary_status "$uuid" - -# remove dictionary -$CLICKHOUSE_CLIENT -q "DROP DICTIONARY dict" -$CLICKHOUSE_CLIENT -q "DROP TABLE data" -echo 'status after drop' -get_dictionary_status "$uuid" From bb47e2cc234baab26d018f081cb257ff1d0b9cf0 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 30 Aug 2023 20:56:14 +0200 Subject: [PATCH 03/23] Remove CurrentStatusInfo --- .../testdata/configs/xml/config.xml | 21 ------------------- .../testdata/configs/yandex_xml/config.xml | 21 ------------------- programs/server/config.xml | 2 -- .../test_config_xml_full/configs/config.xml | 21 ------------------- 4 files changed, 65 deletions(-) diff --git a/programs/diagnostics/testdata/configs/xml/config.xml b/programs/diagnostics/testdata/configs/xml/config.xml index c08b0b2970f..50352ca800e 100644 --- a/programs/diagnostics/testdata/configs/xml/config.xml +++ b/programs/diagnostics/testdata/configs/xml/config.xml @@ -760,27 +760,6 @@ --> - - - - - - - - diff --git a/tests/integration/test_config_xml_full/configs/config.xml b/tests/integration/test_config_xml_full/configs/config.xml index d142df18af8..ac59b3428e8 100644 --- a/tests/integration/test_config_xml_full/configs/config.xml +++ b/tests/integration/test_config_xml_full/configs/config.xml @@ -674,27 +674,6 @@ --> - - - -