Skip to content

Commit

Permalink
*: Remove useless Macros/Graphite (#9805)
Browse files Browse the repository at this point in the history
ref #6233

Remove useless `Macros`/`Graphite`

* Remove `Graphite` related codes. TiFlash only report metrics to `Prometheus`
  * Remove `MetricsTransmitter` that send metrics to `Graphite`
  * Remove `GraphiteWriter` in `BaseDaemon`
  * Remove `StorageSystemGraphite`
* Remove `Macros` that clickhouse use to substitute macro for `ReplicatedReplacingMergeTree`
  * Remove `StorageSystemMacros`
* Remove useless config `user_files_path`, `format_schema_path`
* Always use `profiles.default` as the setting prefix
  • Loading branch information
JaySon-Huang authored Jan 23, 2025
1 parent 9695ea8 commit 405e56a
Show file tree
Hide file tree
Showing 20 changed files with 10 additions and 1,034 deletions.
93 changes: 0 additions & 93 deletions dbms/src/Common/Macros.cpp

This file was deleted.

59 changes: 0 additions & 59 deletions dbms/src/Common/Macros.h

This file was deleted.

2 changes: 1 addition & 1 deletion dbms/src/Interpreters/AsynchronousMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void AsynchronousMetrics::run()

std::unique_lock lock{wait_mutex};

/// Next minute + 30 seconds. To be distant with moment of transmission of metrics, see MetricsTransmitter.
/// Next minute + 30 seconds. To be distant with moment of transmission of metrics.
const auto get_next_minute = [] {
return std::chrono::time_point_cast<std::chrono::minutes, std::chrono::steady_clock>(
std::chrono::steady_clock::now() + std::chrono::minutes(1))
Expand Down
64 changes: 6 additions & 58 deletions dbms/src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <Common/DNSCache.h>
#include <Common/FailPoint.h>
#include <Common/FmtUtils.h>
#include <Common/Macros.h>
#include <Common/Stopwatch.h>
#include <Common/TiFlashMetrics.h>
#include <Common/TiFlashSecurity.h>
Expand Down Expand Up @@ -137,15 +136,13 @@ struct ContextShared
String path; /// Path to the primary data directory, with a slash at the end.
String tmp_path; /// The path to the temporary files that occur when processing the request.
String flags_path; /// Path to the directory with some control flags for server maintenance.
String user_files_path; /// Path to the directory with user provided files, usable by 'file' table function.
PathPool
path_pool; /// The data directories. RegionPersister and some Storage Engine like DeltaMerge will use this to manage data placement on disks.
ConfigurationPtr config; /// Global configuration settings.

Databases databases; /// List of databases and tables in them.
FormatFactory format_factory; /// Formats.
String default_profile_name; /// Default profile name used for default values.
String system_profile_name; /// Profile used by system processes
std::shared_ptr<ISecurityManager> security_manager; /// Known users.
Quotas quotas; /// Known quotas for resource use.
mutable DBGInvoker dbg_invoker; /// Execute inner functions, debug only.
Expand All @@ -163,8 +160,6 @@ struct ContextShared
BackgroundProcessingPoolPtr
ps_compact_background_pool; /// The thread pool for the background work performed by the ps v2.
mutable TMTContextPtr tmt_context; /// Context of TiFlash. Note that this should be free before background_pool.
MultiVersion<Macros> macros; /// Substitutions extracted from config.
String format_schema_path; /// Path to a directory that contains schema files used by input formats.

SharedQueriesPtr shared_queries; /// The cache of shared queries.
SchemaSyncServicePtr schema_sync_service; /// Schema sync service instance.
Expand Down Expand Up @@ -553,12 +548,6 @@ String Context::getFlagsPath() const
return shared->flags_path;
}

String Context::getUserFilesPath() const
{
auto lock = getLock();
return shared->user_files_path;
}

PathPool & Context::getPathPool() const
{
auto lock = getLock();
Expand All @@ -576,9 +565,6 @@ void Context::setPath(const String & path)

if (shared->flags_path.empty())
shared->flags_path = shared->path + "flags/";

if (shared->user_files_path.empty())
shared->user_files_path = shared->path + "user_files/";
}

void Context::setTemporaryPath(const String & path)
Expand All @@ -593,12 +579,6 @@ void Context::setFlagsPath(const String & path)
shared->flags_path = path;
}

void Context::setUserFilesPath(const String & path)
{
auto lock = getLock();
shared->user_files_path = path;
}

void Context::setPathPool(
const Strings & main_data_paths,
const Strings & latest_data_paths,
Expand Down Expand Up @@ -653,8 +633,7 @@ TiFlashSecurityConfigPtr Context::getSecurityConfig()

void Context::reloadDeltaTreeConfig(const Poco::Util::AbstractConfiguration & config)
{
auto default_profile_name = config.getString("default_profile", "default");
String elem = "profiles." + default_profile_name;
String elem = "profiles.default";
if (!config.has(elem))
{
return;
Expand Down Expand Up @@ -691,7 +670,7 @@ void Context::calculateUserSettings()
settings = Settings();

/// 2) Apply settings from default profile ("profiles.*" in `users_config`)
auto default_profile_name = getDefaultProfileName();
auto default_profile_name = shared->default_profile_name;
if (profile_name != default_profile_name)
settings.setProfile(default_profile_name, *shared->users_config);

Expand Down Expand Up @@ -1249,16 +1228,6 @@ void Context::setDefaultFormat(const String & name)
default_format = name;
}

MultiVersion<Macros>::Version Context::getMacros() const
{
return shared->macros.get();
}

void Context::setMacros(std::unique_ptr<Macros> && macros)
{
shared->macros.set(std::move(macros));
}

const Context & Context::getQueryContext() const
{
if (!query_context)
Expand Down Expand Up @@ -2059,7 +2028,7 @@ void Context::reloadConfig() const
{
/// Use mutex if callback may be changed after startup.
if (!shared->config_reload_callback)
throw Exception("Can't reload config beacuse config_reload_callback is not set.", ErrorCodes::LOGICAL_ERROR);
throw Exception("Can't reload config because config_reload_callback is not set.", ErrorCodes::LOGICAL_ERROR);

shared->config_reload_callback();
}
Expand All @@ -2083,34 +2052,13 @@ void Context::setApplicationType(ApplicationType type)
shared->application_type = type;
}

void Context::setDefaultProfiles(const Poco::Util::AbstractConfiguration & config)
void Context::setDefaultProfiles()
{
shared->default_profile_name = config.getString("default_profile", "default");
shared->system_profile_name = config.getString("system_profile", shared->default_profile_name);
setSetting("profile", shared->system_profile_name);
shared->default_profile_name = "default";
setSetting("profile", shared->default_profile_name);
is_config_loaded = true;
}

String Context::getDefaultProfileName() const
{
return shared->default_profile_name;
}

String Context::getSystemProfileName() const
{
return shared->system_profile_name;
}

String Context::getFormatSchemaPath() const
{
return shared->format_schema_path;
}

void Context::setFormatSchemaPath(const String & path)
{
shared->format_schema_path = path;
}

SharedQueriesPtr Context::getSharedQueries()
{
auto lock = getLock();
Expand Down
14 changes: 2 additions & 12 deletions dbms/src/Interpreters/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class TMTContext;
using TMTContextPtr = std::shared_ptr<TMTContext>;
class ProcessList;
class ProcessListElement;
class Macros;
struct Progress;
class QueryLog;
class IDatabase;
Expand Down Expand Up @@ -308,9 +307,6 @@ class Context
String getDefaultFormat() const; /// If default_format is not specified, some global default format is returned.
void setDefaultFormat(const String & name);

MultiVersion<Macros>::Version getMacros() const;
void setMacros(std::unique_ptr<Macros> && macros);

Settings getSettings() const;
void setSettings(const Settings & settings_);

Expand Down Expand Up @@ -514,18 +510,12 @@ class Context
ApplicationType getApplicationType() const;
void setApplicationType(ApplicationType type);

/// Sets default_profile and system_profile, must be called once during the initialization
void setDefaultProfiles(const Poco::Util::AbstractConfiguration & config);
String getDefaultProfileName() const;
String getSystemProfileName() const;
/// Sets default_profile, must be called once during the initialization
void setDefaultProfiles();

void setServerInfo(const ServerInfo & server_info);
const std::optional<ServerInfo> & getServerInfo() const;

/// Base path for format schemas
String getFormatSchemaPath() const;
void setFormatSchemaPath(const String & path);

SharedQueriesPtr getSharedQueries();

const TimezoneInfo & getTimezoneInfo() const { return timezone_info; }
Expand Down
1 change: 0 additions & 1 deletion dbms/src/Server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ target_include_directories (server_for_test PRIVATE ${TiFlash_SOURCE_DIR}/contri

add_library (tiflash-server-lib
CertificateReloader.cpp
MetricsTransmitter.cpp
MetricsPrometheus.cpp
ServerInfo.cpp
Server.cpp
Expand Down
Loading

0 comments on commit 405e56a

Please sign in to comment.