From 933ec28e317504bd2c323eb0a9bdfd65d1c1ff23 Mon Sep 17 00:00:00 2001 From: hehechen Date: Tue, 9 Nov 2021 14:59:45 +0800 Subject: [PATCH 1/9] modify tiflash default config --- contrib/tiflash-proxy | 2 +- dbms/src/Core/Defines.h | 8 ++++ dbms/src/Server/HTTPHandler.cpp | 2 +- dbms/src/Server/MetricsPrometheus.cpp | 23 ++++------- dbms/src/Server/Server.cpp | 38 ++++++++++--------- dbms/src/Server/TCPHandler.h | 2 +- libs/libdaemon/src/BaseDaemon.cpp | 6 +-- .../src/tests/gtest_daemon_config.cpp | 16 +++++++- .../src/ReloadableSplitterChannel.cpp | 2 +- 9 files changed, 57 insertions(+), 42 deletions(-) diff --git a/contrib/tiflash-proxy b/contrib/tiflash-proxy index fdae830d7c9..be82655eb40 160000 --- a/contrib/tiflash-proxy +++ b/contrib/tiflash-proxy @@ -1 +1 @@ -Subproject commit fdae830d7c930063a571688d99f373250e450e12 +Subproject commit be82655eb40b07a55f5fcb35890adbe1e3a4944e diff --git a/dbms/src/Core/Defines.h b/dbms/src/Core/Defines.h index c9e292f5e5a..479d9921ef5 100644 --- a/dbms/src/Core/Defines.h +++ b/dbms/src/Core/Defines.h @@ -88,6 +88,14 @@ #define PLATFORM_NOT_SUPPORTED "The only supported platforms are x86_64 and AArch64 (work in progress)" +#define DEFAULT_MARK_CACHE_SIZE 5368709120 + +#define DEFAULT_METRICS_PORT 8234 + +#define DEFAULT_PROXY_ADDR "127.0.0.1:20170" + +#define DEFAULT_HTTP_PORT 8123 + #if !defined(__x86_64__) && !defined(__aarch64__) // #error PLATFORM_NOT_SUPPORTED #endif diff --git a/dbms/src/Server/HTTPHandler.cpp b/dbms/src/Server/HTTPHandler.cpp index 5f820999892..5fa58e2720f 100644 --- a/dbms/src/Server/HTTPHandler.cpp +++ b/dbms/src/Server/HTTPHandler.cpp @@ -171,7 +171,7 @@ HTTPHandler::HTTPHandler(IServer & server_) : server(server_) , log(&Poco::Logger::get("HTTPHandler")) { - server_display_name = server.config().getString("display_name", getFQDNOrHostName()); + server_display_name = server.config().getString("display_name", "TiFlash"); } diff --git a/dbms/src/Server/MetricsPrometheus.cpp b/dbms/src/Server/MetricsPrometheus.cpp index f31b203f60c..4173a60130f 100644 --- a/dbms/src/Server/MetricsPrometheus.cpp +++ b/dbms/src/Server/MetricsPrometheus.cpp @@ -174,25 +174,18 @@ MetricsPrometheus::MetricsPrometheus( } } - if (conf.hasOption(status_metrics_port)) + auto metrics_port = conf.getString(status_metrics_port, DB::toString(DEFAULT_METRICS_PORT)); + if (security_config.has_tls_config) { - auto metrics_port = conf.getString(status_metrics_port); - if (security_config.has_tls_config) - { - server = getHTTPServer(security_config, tiflash_metrics.registry, metrics_port); - server->start(); - LOG_INFO(log, "Enable prometheus secure pull mode; Metrics Port = " << metrics_port); - } - else - { - exposer = std::make_shared(metrics_port); - exposer->RegisterCollectable(tiflash_metrics.registry); - LOG_INFO(log, "Enable prometheus pull mode; Metrics Port = " << metrics_port); - } + server = getHTTPServer(security_config, tiflash_metrics.registry, metrics_port); + server->start(); + LOG_INFO(log, "Enable prometheus secure pull mode; Metrics Port = " << metrics_port); } else { - LOG_INFO(log, "Disable prometheus pull mode"); + exposer = std::make_shared(metrics_port); + exposer->RegisterCollectable(tiflash_metrics.registry); + LOG_INFO(log, "Enable prometheus pull mode; Metrics Port = " << metrics_port); } timer.scheduleAtFixedRate( diff --git a/dbms/src/Server/Server.cpp b/dbms/src/Server/Server.cpp index 1dd55305ad6..aa05539af5d 100644 --- a/dbms/src/Server/Server.cpp +++ b/dbms/src/Server/Server.cpp @@ -221,6 +221,7 @@ struct TiFlashProxyConfig const char * engine_store_address = "engine-addr"; const char * engine_store_advertise_address = "advertise-engine-addr"; const char * pd_endpoints = "pd-endpoints"; + const char * addr = "addr"; explicit TiFlashProxyConfig(Poco::Util::LayeredConfiguration & config) { @@ -239,6 +240,7 @@ struct TiFlashProxyConfig args_map[pd_endpoints] = config.getString("raft.pd_addr"); args_map[engine_store_version] = TiFlashBuildInfo::getReleaseVersion(); args_map[engine_store_git_hash] = TiFlashBuildInfo::getGitHash(); + args_map[addr] = config.getString("flash.proxy.addr", DEFAULT_PROXY_ADDR); if (!args_map.count(engine_store_address)) args_map[engine_store_address] = config.getString("flash.service_addr"); else @@ -627,23 +629,6 @@ class Server::TcpHttpServersHolder /// For testing purposes, user may omit tcp_port or http_port or https_port in configuration file. try { - /// HTTP - if (config.has("http_port")) - { - if (security_config.has_tls_config) - { - throw Exception("tls config is set but https_port is not set ", ErrorCodes::INVALID_CONFIG_PARAMETER); - } - Poco::Net::ServerSocket socket; - auto address = socket_bind_listen(socket, listen_host, config.getInt("http_port")); - socket.setReceiveTimeout(settings.http_receive_timeout); - socket.setSendTimeout(settings.http_send_timeout); - servers.emplace_back( - new HTTPServer(new HTTPHandlerFactory(server, "HTTPHandler-factory"), server_pool, socket, http_params)); - - LOG_INFO(log, "Listening http://" + address.toString()); - } - /// HTTPS if (config.has("https_port")) { @@ -681,6 +666,23 @@ class Server::TcpHttpServersHolder ErrorCodes::SUPPORT_IS_DISABLED}; #endif } + else + { + /// HTTP + if (security_config.has_tls_config) + { + throw Exception("tls config is set but https_port is not set ", ErrorCodes::INVALID_CONFIG_PARAMETER); + } + Poco::Net::ServerSocket socket; + auto address = socket_bind_listen(socket, listen_host, config.getInt("http_port", DEFAULT_HTTP_PORT)); + socket.setReceiveTimeout(settings.http_receive_timeout); + socket.setSendTimeout(settings.http_send_timeout); + servers.emplace_back( + new HTTPServer(new HTTPHandlerFactory(server, "HTTPHandler-factory"), server_pool, socket, http_params)); + + LOG_INFO(log, "Listening http://" + address.toString()); + } + /// TCP if (config.has("tcp_port")) @@ -1159,7 +1161,7 @@ int Server::main(const std::vector & /*args*/) Settings & settings = global_context->getSettingsRef(); /// Size of cache for marks (index of MergeTree family of tables). It is necessary. - size_t mark_cache_size = config().getUInt64("mark_cache_size"); + size_t mark_cache_size = config().getUInt64("mark_cache_size", DEFAULT_MARK_CACHE_SIZE); if (mark_cache_size) global_context->setMarkCache(mark_cache_size); diff --git a/dbms/src/Server/TCPHandler.h b/dbms/src/Server/TCPHandler.h index 53ef2d0d4bd..a7c7c2abe9c 100644 --- a/dbms/src/Server/TCPHandler.h +++ b/dbms/src/Server/TCPHandler.h @@ -87,7 +87,7 @@ class TCPHandler : public Poco::Net::TCPServerConnection , connection_context(server.context()) , query_context(server.context()) { - server_display_name = server.config().getString("display_name", getFQDNOrHostName()); + server_display_name = server.config().getString("display_name", "TiFlash"); } void run(); diff --git a/libs/libdaemon/src/BaseDaemon.cpp b/libs/libdaemon/src/BaseDaemon.cpp index 3028e497546..7ec32b1ae91 100644 --- a/libs/libdaemon/src/BaseDaemon.cpp +++ b/libs/libdaemon/src/BaseDaemon.cpp @@ -733,7 +733,7 @@ void BaseDaemon::buildLoggers(Poco::Util::AbstractConfiguration & config) return; config_logger = current_logger; - bool is_daemon = config.getBool("application.runAsDaemon", false); + bool is_daemon = config.getBool("application.runAsDaemon", true); // Split log and error log. Poco::AutoPtr split = new Poco::ReloadableSplitterChannel; @@ -755,7 +755,7 @@ void BaseDaemon::buildLoggers(Poco::Util::AbstractConfiguration & config) log_file->setProperty(Poco::FileChannel::PROP_TIMES, "local"); log_file->setProperty(Poco::FileChannel::PROP_ARCHIVE, "timestamp"); log_file->setProperty(Poco::FileChannel::PROP_COMPRESS, /*config.getRawString("logger.compress", "true")*/ "true"); - log_file->setProperty(Poco::FileChannel::PROP_PURGECOUNT, config.getRawString("logger.count", "1")); + log_file->setProperty(Poco::FileChannel::PROP_PURGECOUNT, config.getRawString("logger.count", "10")); log_file->setProperty(Poco::FileChannel::PROP_FLUSH, config.getRawString("logger.flush", "true")); log_file->setProperty(Poco::FileChannel::PROP_ROTATEONOPEN, config.getRawString("logger.rotateOnOpen", "false")); log->setChannel(log_file); @@ -779,7 +779,7 @@ void BaseDaemon::buildLoggers(Poco::Util::AbstractConfiguration & config) error_log_file->setProperty(Poco::FileChannel::PROP_TIMES, "local"); error_log_file->setProperty(Poco::FileChannel::PROP_ARCHIVE, "timestamp"); error_log_file->setProperty(Poco::FileChannel::PROP_COMPRESS, /*config.getRawString("logger.compress", "true")*/ "true"); - error_log_file->setProperty(Poco::FileChannel::PROP_PURGECOUNT, config.getRawString("logger.count", "1")); + error_log_file->setProperty(Poco::FileChannel::PROP_PURGECOUNT, config.getRawString("logger.count", "10")); error_log_file->setProperty(Poco::FileChannel::PROP_FLUSH, config.getRawString("logger.flush", "true")); error_log_file->setProperty(Poco::FileChannel::PROP_ROTATEONOPEN, config.getRawString("logger.rotateOnOpen", "false")); errorlog->setChannel(error_log_file); diff --git a/libs/libdaemon/src/tests/gtest_daemon_config.cpp b/libs/libdaemon/src/tests/gtest_daemon_config.cpp index 6fe6ecb03a7..50f04ead350 100644 --- a/libs/libdaemon/src/tests/gtest_daemon_config.cpp +++ b/libs/libdaemon/src/tests/gtest_daemon_config.cpp @@ -47,7 +47,7 @@ static void verifyChannelConfig(Poco::Channel & channel, Poco::Util::AbstractCon { Poco::TiFlashLogFileChannel * fileChannel = dynamic_cast(&channel); ASSERT_EQ(fileChannel->getProperty(Poco::FileChannel::PROP_ROTATION), config.getRawString("logger.size", "100M")); - ASSERT_EQ(fileChannel->getProperty(Poco::FileChannel::PROP_PURGECOUNT), config.getRawString("logger.count", "1")); + ASSERT_EQ(fileChannel->getProperty(Poco::FileChannel::PROP_PURGECOUNT), config.getRawString("logger.count", "10")); return; } if (typeid(channel) == typeid(Poco::LevelFilterChannel)) @@ -68,6 +68,19 @@ try { DB::Strings tests = { R"( +[application] +runAsDaemon = false +[profiles] +[profiles.default] +max_rows_in_set = 455 +dt_page_gc_low_write_prob = 0.2 +[logger] +errorlog = "./tmp/log/tiflash_error.log" +level = "debug" +log = "./tmp/log/tiflash.log" +size = "1K" + )", + R"( [profiles] [profiles.default] max_rows_in_set = 455 @@ -87,7 +100,6 @@ runAsDaemon = false max_rows_in_set = 455 dt_page_gc_low_write_prob = 0.2 [logger] -count = 10 errorlog = "./tmp/log/tiflash_error.log" level = "debug" log = "./tmp/log/tiflash.log" diff --git a/libs/libpocoext/src/ReloadableSplitterChannel.cpp b/libs/libpocoext/src/ReloadableSplitterChannel.cpp index 2b6b47d71fb..6e31bdfccce 100644 --- a/libs/libpocoext/src/ReloadableSplitterChannel.cpp +++ b/libs/libpocoext/src/ReloadableSplitterChannel.cpp @@ -11,7 +11,7 @@ void ReloadableSplitterChannel::setPropertiesRecursively(Channel & channel, Util { TiFlashLogFileChannel * fileChannel = dynamic_cast(&channel); fileChannel->setProperty(FileChannel::PROP_ROTATION, config.getRawString("logger.size", "100M")); - fileChannel->setProperty(FileChannel::PROP_PURGECOUNT, config.getRawString("logger.count", "1")); + fileChannel->setProperty(FileChannel::PROP_PURGECOUNT, config.getRawString("logger.count", "10")); return; } if (typeid(channel) == typeid(LevelFilterChannel)) From d787e3d6d71bc929c6965752a7f085cd50baacfe Mon Sep 17 00:00:00 2001 From: hehechen Date: Tue, 9 Nov 2021 22:31:41 +0800 Subject: [PATCH 2/9] fix issue --- dbms/src/Core/Defines.h | 2 +- dbms/src/Server/Server.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dbms/src/Core/Defines.h b/dbms/src/Core/Defines.h index 479d9921ef5..b593860705c 100644 --- a/dbms/src/Core/Defines.h +++ b/dbms/src/Core/Defines.h @@ -88,7 +88,7 @@ #define PLATFORM_NOT_SUPPORTED "The only supported platforms are x86_64 and AArch64 (work in progress)" -#define DEFAULT_MARK_CACHE_SIZE 5368709120 +#define DEFAULT_MARK_CACHE_SIZE (5ULL * 1024 * 1024 * 1024) #define DEFAULT_METRICS_PORT 8234 diff --git a/dbms/src/Server/Server.cpp b/dbms/src/Server/Server.cpp index aa05539af5d..78dc7a71dab 100644 --- a/dbms/src/Server/Server.cpp +++ b/dbms/src/Server/Server.cpp @@ -216,12 +216,12 @@ struct TiFlashProxyConfig std::unordered_map val_map; bool is_proxy_runnable = false; - const char * engine_store_version = "engine-version"; - const char * engine_store_git_hash = "engine-git-hash"; - const char * engine_store_address = "engine-addr"; - const char * engine_store_advertise_address = "advertise-engine-addr"; - const char * pd_endpoints = "pd-endpoints"; - const char * addr = "addr"; + const String engine_store_version = "engine-version"; + const String engine_store_git_hash = "engine-git-hash"; + const String engine_store_address = "engine-addr"; + const String engine_store_advertise_address = "advertise-engine-addr"; + const String pd_endpoints = "pd-endpoints"; + const String addr = "addr"; explicit TiFlashProxyConfig(Poco::Util::LayeredConfiguration & config) { From ec7791ac15bbfb40e31d5e35ddbdf47af92aebe0 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Wed, 10 Nov 2021 17:07:53 +0800 Subject: [PATCH 3/9] Update proxy hash Signed-off-by: JaySon-Huang --- contrib/tiflash-proxy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/tiflash-proxy b/contrib/tiflash-proxy index be82655eb40..defbe27e00a 160000 --- a/contrib/tiflash-proxy +++ b/contrib/tiflash-proxy @@ -1 +1 @@ -Subproject commit be82655eb40b07a55f5fcb35890adbe1e3a4944e +Subproject commit defbe27e00ac7b40c4987bb58f265099effda83f From 295b764de872a166cf1baea041cdc8aec8e421d2 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Wed, 10 Nov 2021 17:30:38 +0800 Subject: [PATCH 4/9] Update MetricsPrometheus Signed-off-by: JaySon-Huang --- dbms/src/Common/Timer.h | 4 ++-- dbms/src/Server/MetricsPrometheus.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dbms/src/Common/Timer.h b/dbms/src/Common/Timer.h index 12192b5d932..40d6d421664 100644 --- a/dbms/src/Common/Timer.h +++ b/dbms/src/Common/Timer.h @@ -5,9 +5,9 @@ namespace DB { -struct Timer : Poco::Util::Timer +struct Timer : public Poco::Util::Timer { - Timer(const char * name) + explicit Timer(const char * name) : thread_worker_name(name) {} diff --git a/dbms/src/Server/MetricsPrometheus.cpp b/dbms/src/Server/MetricsPrometheus.cpp index 4173a60130f..fccb84290b5 100644 --- a/dbms/src/Server/MetricsPrometheus.cpp +++ b/dbms/src/Server/MetricsPrometheus.cpp @@ -90,7 +90,12 @@ std::shared_ptr getHTTPServer( const std::weak_ptr & collectable, const String & metrics_port) { - Poco::Net::Context::Ptr context = new Poco::Net::Context(Poco::Net::Context::TLSV1_2_SERVER_USE, security_config.key_path, security_config.cert_path, security_config.ca_path, Poco::Net::Context::VerificationMode::VERIFY_STRICT); + Poco::Net::Context::Ptr context = new Poco::Net::Context( + Poco::Net::Context::TLSV1_2_SERVER_USE, + security_config.key_path, + security_config.cert_path, + security_config.ca_path, + Poco::Net::Context::VerificationMode::VERIFY_STRICT); std::function check_common_name = [&](const Poco::Crypto::X509Certificate & cert) { if (security_config.allowed_common_names.empty()) @@ -127,6 +132,8 @@ MetricsPrometheus::MetricsPrometheus( auto & tiflash_metrics = TiFlashMetrics::instance(); auto & conf = context.getConfigRef(); + // Interval to collect `ProfileEvents::Event`/`CurrentMetrics::Metric`/`AsynchronousMetrics` + // When push mode is enabled, it also define the interval that Prometheus client push to pushgateway. metrics_interval = conf.getInt(status_metrics_interval, 15); if (metrics_interval < 5) { @@ -140,6 +147,7 @@ MetricsPrometheus::MetricsPrometheus( } LOG_INFO(log, "Config: " << status_metrics_interval << " = " << metrics_interval); + // Usually TiFlash disable prometheus push mode when deployed by TiUP/TiDB-Operator if (!conf.hasOption(status_metrics_addr)) { LOG_INFO(log, "Disable prometheus push mode, cause " << status_metrics_addr << " is not set!"); @@ -174,6 +182,7 @@ MetricsPrometheus::MetricsPrometheus( } } + // Usually TiFlash enable prometheus pull mode when deployed by TiUP/TiDB-Operator auto metrics_port = conf.getString(status_metrics_port, DB::toString(DEFAULT_METRICS_PORT)); if (security_config.has_tls_config) { @@ -237,8 +246,7 @@ void MetricsPrometheus::run() if (gateway != nullptr) { - auto return_code = gateway->Push(); - if (return_code != 200) + if (auto return_code = gateway->Push(); return_code != 200) { LOG_WARNING(log, "Failed to push metrics to gateway, return code is " << return_code); } From 984e3a4fdc65c16768fc2b4e6451a60d0001c3e5 Mon Sep 17 00:00:00 2001 From: hehechen Date: Thu, 11 Nov 2021 15:58:51 +0800 Subject: [PATCH 5/9] modify config-template.toml --- etc/config-template.toml | 46 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/etc/config-template.toml b/etc/config-template.toml index 01975844d93..5f6db68a26a 100644 --- a/etc/config-template.toml +++ b/etc/config-template.toml @@ -1,15 +1,13 @@ -# display_name = "TiFlash" - ## The listening host for supporting services such as TPC/HTTP. It is recommended to configure it as "0.0.0.0", which means to listen on all IP addresses of this machine. # listen_host = "0.0.0.0" -## The cache size limit of the metadata of a data block. Generally, you do not need to change this value. -# mark_cache_size = 5368709120 -## The cache size limit of the min-max index of a data block. Generally, you do not need to change this value. -# minmax_index_cache_size = 5368709120 ## The TiFlash TCP service port. # tcp_port = 9000 ## The TiFlash HTTP service port. # http_port = 8123 +## The cache size limit of the metadata of a data block. Generally, you do not need to change this value. +# mark_cache_size = 5368709120 +## The cache size limit of the min-max index of a data block. Generally, you do not need to change this value. +# minmax_index_cache_size = 5368709120 ## The path in which the TiFlash temporary files are stored. By default it is the first directory in storage.latest.dir appended with "/tmp". # tmp_path = "/tidb-data/tiflash-9000/tmp" @@ -90,31 +88,36 @@ [flash] # tidb_status_addr = "tidb0:10080" # service_addr = "0.0.0.0:3930" -# compact_log_min_period = "120" -# compact_log_min_rows = "40960" -# compact_log_min_bytes = "33554432" -# replica_read_max_thread = "1" -# batch_read_index_timeout_ms = "10000" -# wait_index_timeout_ms = "300000" -# wait_region_ready_timeout_sec = "1200" +# compact_log_min_period = 120 +# overlap_threshold = 0.6 +# compact_log_min_rows = 40960 +# compact_log_min_bytes = 33554432 +# replica_read_max_thread = 1 +# batch_read_index_timeout_ms = 10000 +# wait_index_timeout_ms = 300000 +# wait_region_ready_timeout_sec = 1200 [flash.flash_cluster] -# update_rule_interval = 5 +# update_rule_interval = 10 +# master_ttl = 60 +# cluster_manager_path = "./flash_cluster_manager" +# log = "[tmp_path]/flash_cluster_manager.log" [flash.proxy] # addr = "0.0.0.0:20170" # advertise-addr = "tiflash0:20170" # data-dir = "/data" # config = "/proxy.toml" # log-file = "/log/proxy.log" -# engine-addr = "tiflash0:3930" +# log-level = "info" # status-addr = "0.0.0.0:20181" # advertise-status-addr = "tiflash0:20181" +# engine-addr = "tiflash0:3930" [logger] -# count = 10 -# errorlog = "/tmp/tiflash/log/error.log" -# size = "1000M" # log = "/tmp/tiflash/log/server.log" -# level = "trace" +# level = "debug" +# errorlog = "/tmp/tiflash/log/error.log" +# size = "100M" +# count = 10 [application] # runAsDaemon = true @@ -130,6 +133,11 @@ # The value is one of "block" / "file1" / "file2". # method = "file1" +[status] +# The port through which Prometheus pulls metrics information. +# metrics_port = 8234 +# metrics_interval = 15 + [profiles] [profiles.default] ## The default value is true. This parameter determines whether the segment From 09ab34754addeaa82bdcb39d8ac92d64f0ad5843 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Tue, 16 Nov 2021 11:36:35 +0800 Subject: [PATCH 6/9] Remove useless config Signed-off-by: JaySon-Huang --- etc/config-template.toml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/etc/config-template.toml b/etc/config-template.toml index 5f6db68a26a..e5f5af6289f 100644 --- a/etc/config-template.toml +++ b/etc/config-template.toml @@ -119,9 +119,6 @@ # size = "100M" # count = 10 -[application] -# runAsDaemon = true - [raft] # pd_addr = "pd0:2379" # ignore_databases = "system,default" @@ -155,8 +152,8 @@ # cop_pool_size = 0 ## New in v5.0. This item specifies the maximum number of batch requests that TiFlash Coprocessor executes at the same time. If the number of requests exceeds the specified value, the exceeded requests will queue. If the configuration value is set to 0 or not set, the default value is used, which is twice the number of physical cores. # batch_cop_pool_size = 0 -## Security settings take effect starting from v4.0.5. +## Security settings take effect starting from v4.0.5. [security] ## Path of the file that contains a list of trusted SSL CAs. If set, the following settings ## cert_path and key_path are also needed. @@ -168,4 +165,4 @@ ## New in v5.0. This configuration item enables or disables log redaction. If the configuration value ## is set to true, all user data in the log will be replaced by ?. ## Note that you also need to set security.redact-info-log for tiflash-learner's logging in tiflash-learner.toml. -# redact_info_log = false \ No newline at end of file +# redact_info_log = false From e1a679c45ea6fd15fd4e47826d9e9f4087977368 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Tue, 16 Nov 2021 11:37:39 +0800 Subject: [PATCH 7/9] Remove single file format for applying snapshot Signed-off-by: JaySon-Huang --- dbms/src/Server/RaftConfigParser.cpp | 37 ++++++++++++++-------------- etc/config-template.toml | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/dbms/src/Server/RaftConfigParser.cpp b/dbms/src/Server/RaftConfigParser.cpp index e80ae35b7f5..65c3e0697b9 100644 --- a/dbms/src/Server/RaftConfigParser.cpp +++ b/dbms/src/Server/RaftConfigParser.cpp @@ -77,7 +77,7 @@ TiFlashRaftConfig TiFlashRaftConfig::parseSettings(Poco::Util::LayeredConfigurat { if (config.has(disable_bg_flush_conf) && config.getBool(disable_bg_flush_conf)) throw Exception("Illegal arguments: disable background flush while using engine " + MutableSupport::txn_storage_name, - ErrorCodes::INVALID_CONFIG_PARAMETER); + ErrorCodes::INVALID_CONFIG_PARAMETER); res.disable_bg_flush = false; } else if (res.engine == ::TiDB::StorageEngine::DT) @@ -86,7 +86,7 @@ TiFlashRaftConfig TiFlashRaftConfig::parseSettings(Poco::Util::LayeredConfigurat /// Which means that we may get the wrong result with outdated schema. if (config.has(disable_bg_flush_conf) && !config.getBool(disable_bg_flush_conf)) throw Exception("Illegal arguments: enable background flush while using engine " + MutableSupport::delta_tree_storage_name, - ErrorCodes::INVALID_CONFIG_PARAMETER); + ErrorCodes::INVALID_CONFIG_PARAMETER); res.disable_bg_flush = true; } @@ -108,31 +108,32 @@ TiFlashRaftConfig TiFlashRaftConfig::parseSettings(Poco::Util::LayeredConfigurat { res.snapshot_apply_method = TiDB::SnapshotApplyMethod::DTFile_Directory; } +#if 0 + // Not generally available for this file format else if (snapshot_method == "file2") { res.snapshot_apply_method = TiDB::SnapshotApplyMethod::DTFile_Single; } +#endif } switch (res.snapshot_apply_method) { - case TiDB::SnapshotApplyMethod::DTFile_Directory: - case TiDB::SnapshotApplyMethod::DTFile_Single: - if (res.engine != TiDB::StorageEngine::DT) - { - throw Exception( - "Illegal arguments: can not use DTFile to store snapshot data when the storage engine is not DeltaTree, [engine=" - + DB::toString(static_cast(res.engine)) - + "] [snapshot method=" + applyMethodToString(res.snapshot_apply_method) + "]", - ErrorCodes::INVALID_CONFIG_PARAMETER); - } - break; - default: - break; + case TiDB::SnapshotApplyMethod::DTFile_Directory: + case TiDB::SnapshotApplyMethod::DTFile_Single: + if (res.engine != TiDB::StorageEngine::DT) + { + throw Exception( + "Illegal arguments: can not use DTFile to store snapshot data when the storage engine is not DeltaTree, [engine=" + + DB::toString(static_cast(res.engine)) + + "] [snapshot method=" + applyMethodToString(res.snapshot_apply_method) + "]", + ErrorCodes::INVALID_CONFIG_PARAMETER); + } + break; + default: + break; } - LOG_INFO(log, - "Default storage engine [type=" << static_cast(res.engine) - << "] [snapshot.method=" << applyMethodToString(res.snapshot_apply_method) << "]"); + LOG_INFO(log, fmt::format("Default storage engine [type={}] [snapshot.method={}]", static_cast(res.engine), applyMethodToString(res.snapshot_apply_method))); return res; } diff --git a/etc/config-template.toml b/etc/config-template.toml index e5f5af6289f..63af9761e22 100644 --- a/etc/config-template.toml +++ b/etc/config-template.toml @@ -127,7 +127,7 @@ [raft.snapshot] # The way to apply snapshot data -# The value is one of "block" / "file1" / "file2". +# The value is one of "block" / "file1" # method = "file1" [status] From 5a8fadd6f6de492f3c6b44e00ff205546030ae56 Mon Sep 17 00:00:00 2001 From: hehechen Date: Tue, 16 Nov 2021 16:42:00 +0800 Subject: [PATCH 8/9] disable pull mode when push mode is configured and status_metrics_port is not configured. --- dbms/src/Server/MetricsPrometheus.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dbms/src/Server/MetricsPrometheus.cpp b/dbms/src/Server/MetricsPrometheus.cpp index fccb84290b5..f9a5796a361 100644 --- a/dbms/src/Server/MetricsPrometheus.cpp +++ b/dbms/src/Server/MetricsPrometheus.cpp @@ -183,18 +183,25 @@ MetricsPrometheus::MetricsPrometheus( } // Usually TiFlash enable prometheus pull mode when deployed by TiUP/TiDB-Operator - auto metrics_port = conf.getString(status_metrics_port, DB::toString(DEFAULT_METRICS_PORT)); - if (security_config.has_tls_config) + if (conf.hasOption(status_metrics_port) || !conf.hasOption(status_metrics_addr)) { - server = getHTTPServer(security_config, tiflash_metrics.registry, metrics_port); - server->start(); - LOG_INFO(log, "Enable prometheus secure pull mode; Metrics Port = " << metrics_port); + auto metrics_port = conf.getString(status_metrics_port, DB::toString(DEFAULT_METRICS_PORT)); + if (security_config.has_tls_config) + { + server = getHTTPServer(security_config, tiflash_metrics.registry, metrics_port); + server->start(); + LOG_INFO(log, "Enable prometheus secure pull mode; Metrics Port = " << metrics_port); + } + else + { + exposer = std::make_shared(metrics_port); + exposer->RegisterCollectable(tiflash_metrics.registry); + LOG_INFO(log, "Enable prometheus pull mode; Metrics Port = " << metrics_port); + } } else { - exposer = std::make_shared(metrics_port); - exposer->RegisterCollectable(tiflash_metrics.registry); - LOG_INFO(log, "Enable prometheus pull mode; Metrics Port = " << metrics_port); + LOG_INFO(log, "Disable prometheus pull mode"); } timer.scheduleAtFixedRate( From 72c91e5f4a636980b07651065b813c56614f5e7c Mon Sep 17 00:00:00 2001 From: hehechen Date: Thu, 18 Nov 2021 14:47:36 +0800 Subject: [PATCH 9/9] Update dbms/src/Server/MetricsPrometheus.cpp Co-authored-by: JaySon --- dbms/src/Server/MetricsPrometheus.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbms/src/Server/MetricsPrometheus.cpp b/dbms/src/Server/MetricsPrometheus.cpp index f9a5796a361..a79105e39c3 100644 --- a/dbms/src/Server/MetricsPrometheus.cpp +++ b/dbms/src/Server/MetricsPrometheus.cpp @@ -182,7 +182,8 @@ MetricsPrometheus::MetricsPrometheus( } } - // Usually TiFlash enable prometheus pull mode when deployed by TiUP/TiDB-Operator + // Usually TiFlash enables Prometheus pull mode when deployed by TiUP/TiDB-Operator. + // Enable pull mode by default when push mode is disabled. if (conf.hasOption(status_metrics_port) || !conf.hasOption(status_metrics_addr)) { auto metrics_port = conf.getString(status_metrics_port, DB::toString(DEFAULT_METRICS_PORT));