This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch dev-1.0.1 in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 81c622bdc3cdc4f1be2162581df006598455d402 Author: Xinyi Zou <zouxiny...@gmail.com> AuthorDate: Wed Jun 1 08:04:24 2022 +0800 [Enhancement] Remove minidump (#9894) --- be/CMakeLists.txt | 5 - be/src/common/config.h | 14 --- be/src/runtime/CMakeLists.txt | 1 - be/src/runtime/minidump.cpp | 169 --------------------------------- be/src/runtime/minidump.h | 64 ------------- be/src/service/doris_main.cpp | 11 --- be/test/runtime/minidump_test.cpp | 81 ---------------- docs/en/developer-guide/minidump.md | 4 +- docs/zh-CN/developer-guide/minidump.md | 4 +- 9 files changed, 6 insertions(+), 347 deletions(-) diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index af3f4ac7e1..491fe69055 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -323,9 +323,6 @@ set_target_properties(minizip PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib add_library(idn STATIC IMPORTED) set_target_properties(idn PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib64/libidn.a) -add_library(breakpad STATIC IMPORTED) -set_target_properties(breakpad PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib64/libbreakpad_client.a) - if (WITH_KERBEROS) # kerberos lib for libhdfs3 add_library(gsasl STATIC IMPORTED) @@ -497,7 +494,6 @@ include_directories( ${GENSRC_DIR}/ ${THIRDPARTY_DIR}/include ${GPERFTOOLS_HOME}/include - ${THIRDPARTY_DIR}/include/breakpad/ ) set(WL_START_GROUP "-Wl,--start-group") @@ -602,7 +598,6 @@ set(COMMON_THIRDPARTY odbc cctz minizip - breakpad ${AWS_LIBS} # put this after lz4 to avoid using lz4 lib in librdkafka librdkafka_cpp diff --git a/be/src/common/config.h b/be/src/common/config.h index 3e4c31eb58..fad7459bef 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -668,20 +668,6 @@ CONF_String(default_remote_storage_s3_region, ""); CONF_mInt32(default_remote_storage_s3_max_conn, "50"); CONF_mInt32(default_remote_storage_s3_request_timeout_ms, "3000"); CONF_mInt32(default_remote_storage_s3_conn_timeout_ms, "1000"); -// Set to true to disable the minidump feature. -CONF_Bool(disable_minidump, "false"); - -// The dir to save minidump file. -// Make sure that the user who run Doris has permission to create and visit this dir, -// So Doris will fail to start. -CONF_String(minidump_dir, "${DORIS_HOME}/minidump"); - -// The max minidump file size in MB. -CONF_Int32(max_minidump_file_size_mb, "200"); - -// The max number of minidump file. -// Doris will only keep latest 10 minidump files by default. -CONF_Int32(max_minidump_file_number, "10"); // If the dependent Kafka version is lower than the Kafka client version that routine load depends on, // the value set by the fallback version kafka_broker_version_fallback will be used, diff --git a/be/src/runtime/CMakeLists.txt b/be/src/runtime/CMakeLists.txt index c35d2e1016..da50458794 100644 --- a/be/src/runtime/CMakeLists.txt +++ b/be/src/runtime/CMakeLists.txt @@ -108,7 +108,6 @@ set(RUNTIME_FILES cache/result_node.cpp cache/result_cache.cpp odbc_table_sink.cpp - minidump.cpp ) if (WITH_MYSQL) diff --git a/be/src/runtime/minidump.cpp b/be/src/runtime/minidump.cpp deleted file mode 100644 index 7d527db020..0000000000 --- a/be/src/runtime/minidump.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "runtime/minidump.h" - -#include <sys/stat.h> -#include <unistd.h> - -#include "common/config.h" -#include "env/env.h" -#include "util/file_utils.h" -#include "util/string_util.h" - -#include "client/linux/handler/exception_handler.h" - -namespace doris { - -int Minidump::_signo = SIGUSR1; -std::unique_ptr<google_breakpad::ExceptionHandler> Minidump::_error_handler = nullptr; - -// Save the absolute path and create_time of a minidump file -struct FileStat { - std::string abs_path; - time_t create_time; - - FileStat(const std::string& path_, time_t ctime) - : abs_path(path_), create_time(ctime) {} -}; - -Status Minidump::init() { - if (config::disable_minidump) { - LOG(INFO) << "minidump is disabled"; - return Status::OK(); - } - - // 1. create minidump dir - RETURN_IF_ERROR(FileUtils::create_dir(config::minidump_dir)); - - // 2. create ExceptionHandler - google_breakpad::MinidumpDescriptor minidump_descriptor(config::minidump_dir); - if (config::max_minidump_file_size_mb > 0) { - minidump_descriptor.set_size_limit(config::max_minidump_file_size_mb * 1024 * 1024); - } - _error_handler.reset(new google_breakpad::ExceptionHandler(minidump_descriptor, nullptr, _minidump_cb, nullptr, true, -1)); - - // 3. setup sig handler - _setup_sig_handler(); - - RETURN_IF_ERROR(Thread::create( - "Minidump", "minidump_clean_thread", - [this]() { this->_clean_old_minidump(); }, &_clean_thread)); - - LOG(INFO) << "Minidump is enabled. dump file will be saved at " << config::minidump_dir; - return Status::OK(); -} - -Status Minidump::_setup_sig_handler() { - struct sigaction sig_action; - memset(&sig_action, 0, sizeof(sig_action)); - sigemptyset(&sig_action.sa_mask); - - sig_action.sa_flags = SA_SIGINFO; // use sa_sigaction instead of sa_handler - sig_action.sa_sigaction = &(this->_usr1_sigaction); - if (sigaction(_signo, &sig_action, nullptr) == -1) { - return Status::InternalError("failed to install signal handler for " + std::to_string(_signo)); - } - return Status::OK(); -} - -void Minidump::_usr1_sigaction(int signum, siginfo_t* info, void* context) { - const char* msg = "Receive signal: SIGUSR1\n"; - sys_write(STDOUT_FILENO, msg, strlen(msg)); - _error_handler->WriteMinidump(); -} - -bool Minidump::_minidump_cb(const google_breakpad::MinidumpDescriptor& descriptor, - void* context, bool succeeded) { - // use sys_write supported by `linux syscall`, recommended by breakpad doc. - const char* msg = "Minidump created at: "; - sys_write(STDOUT_FILENO, msg, strlen(msg)); - msg = descriptor.path(); - sys_write(STDOUT_FILENO, msg, strlen(msg)); - sys_write(STDOUT_FILENO, "\n", 1); - - // Reference from kudu, return false so that breakpad will invoke any - // previously-installed signal handler of glog. - // So that we can get the error stack trace directly in be.out without - // anlayzing minidump file, which is more friendly for debugging. - return false; -} - -void Minidump::stop() { - if (_stop) { - return; - } - _stop = true; - _clean_thread->join(); -} - -void Minidump::_clean_old_minidump() { - while(!_stop) { - sleep(10); - if (config::max_minidump_file_number <= 0) { - continue; - } - - // list all files - std::vector<std::string> files; - FileUtils::list_files(Env::Default(), config::minidump_dir, &files); - for (auto it = files.begin(); it != files.end();) { - if (!ends_with(*it, ".dmp")) { - it = files.erase(it); - } else { - it++; - } - } - if (files.size() <= config::max_minidump_file_number) { - continue; - } - - // check file create time and sort and save in stats - int ret = 0; - std::vector<FileStat> stats; - for (auto it = files.begin(); it != files.end(); ++it) { - std::string path = config::minidump_dir + "/" + *it; - - struct stat buf; - if ((ret = stat(path.c_str(), &buf)) != 0) { - LOG(WARNING) << "Failed to stat minidump file: " << path << ", remote it. errno: " << ret; - FileUtils::remove(path); - continue; - } - - stats.emplace_back(path, buf.st_ctime); - } - - // sort file by ctime ascending - std::sort(stats.begin(), stats.end(), [](const FileStat& f1, const FileStat& f2) { - if (f1.create_time > f2.create_time) { - return false; - } else { - return true; - } - }); - - int to_delete = stats.size() - config::max_minidump_file_number; - int deleted = 0; - for (auto it = stats.begin(); it != stats.end() && deleted < to_delete; it++, deleted++) { - FileUtils::remove(it->abs_path); - } - LOG(INFO) << "delete " << deleted << " minidump files"; - } -} - -} // namespace doris diff --git a/be/src/runtime/minidump.h b/be/src/runtime/minidump.h deleted file mode 100644 index 78e836cd4d..0000000000 --- a/be/src/runtime/minidump.h +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include <signal.h> - -#include "client/linux/handler/exception_handler.h" -#include "common/status.h" -#include "util/thread.h" - -namespace doris { - -// A wrapper of minidump from breakpad. -// Used to write minidump file to config::minidump_dir when BE crashes. -// And user can also trigger to write a minidump by sending SIGUSR1 to BE, eg: -// kill -s SIGUSR1 be_pid -class Minidump { -public: - Minidump() {}; - ~Minidump() {}; - - Status init(); - - // stop and join the minidump clean thread; - void stop(); - -private: - // The callback after writing the minidump file - static bool _minidump_cb(const google_breakpad::MinidumpDescriptor& descriptor, - void* context, bool succeeded); - // The handle function when receiving SIGUSR1 signal. - static void _usr1_sigaction(int signum, siginfo_t* info, void* context); - - // try clean old minidump files periodically. - // To keep at most config::max_minidump_number files. - void _clean_old_minidump(); - - // Setup hanlder for SIGUSR1 - Status _setup_sig_handler(); - -private: - static int _signo; - static std::unique_ptr<google_breakpad::ExceptionHandler> _error_handler; - - std::atomic<bool> _stop = false; - scoped_refptr<Thread> _clean_thread; -}; - -} // namespace doris diff --git a/be/src/service/doris_main.cpp b/be/src/service/doris_main.cpp index cf8f21ef20..d8c4695b25 100644 --- a/be/src/service/doris_main.cpp +++ b/be/src/service/doris_main.cpp @@ -50,7 +50,6 @@ #include "olap/storage_engine.h" #include "runtime/exec_env.h" #include "runtime/heartbeat_flags.h" -#include "runtime/minidump.h" #include "service/backend_options.h" #include "service/backend_service.h" #include "service/brpc_service.h" @@ -468,15 +467,6 @@ int main(int argc, char** argv) { exit(1); } - // 5. init minidump - doris::Minidump minidump; - status = minidump.init(); - if (!status.ok()) { - LOG(ERROR) << "Failed to initialize minidump: " << status.get_error_msg(); - doris::shutdown_logging(); - exit(1); - } - while (!doris::k_doris_exit) { #if defined(LEAK_SANITIZER) __lsan_do_leak_check(); @@ -496,7 +486,6 @@ int main(int argc, char** argv) { be_server->stop(); be_server->join(); engine->stop(); - minidump.stop(); delete be_server; be_server = nullptr; diff --git a/be/test/runtime/minidump_test.cpp b/be/test/runtime/minidump_test.cpp deleted file mode 100644 index e46ca6a749..0000000000 --- a/be/test/runtime/minidump_test.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include <gtest/gtest.h> - -#include "runtime/minidump.h" - -#include "common/config.h" -#include "env/env.h" -#include "util/file_utils.h" -#include "util/logging.h" -#include "util/uid_util.h" - -namespace doris { - -class MinidumpTest : public ::testing::Test { -protected: - virtual void SetUp() { - UniqueId unique_id = UniqueId::gen_uid(); - _tmp_dir = "/tmp/" + unique_id.to_string(); - config::minidump_dir = _tmp_dir; - config::max_minidump_file_number = 5; - _minidump.init(); - } - - virtual void TearDown() { - _minidump.stop(); - FileUtils::remove_all(_tmp_dir); - } - - Minidump _minidump; - std::string _tmp_dir; -}; - -TEST_F(MinidumpTest, testNormal) { - std::vector<std::string> files; - kill(getpid(), SIGUSR1); - usleep(500000); - FileUtils::list_files(Env::Default(), config::minidump_dir, &files); - EXPECT_EQ(1, files.size()); - - // kill 5 times - kill(getpid(), SIGUSR1); - kill(getpid(), SIGUSR1); - kill(getpid(), SIGUSR1); - kill(getpid(), SIGUSR1); - kill(getpid(), SIGUSR1); - usleep(500000); - files.clear(); - FileUtils::list_files(Env::Default(), config::minidump_dir, &files); - EXPECT_EQ(6, files.size()); - - // sleep 10 seconds to wait it clean - sleep(10); - files.clear(); - FileUtils::list_files(Env::Default(), config::minidump_dir, &files); - EXPECT_EQ(5, files.size()); -} - - -} // end namespace doris - -int main(int argc, char** argv) { - doris::init_glog("be-test"); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/docs/en/developer-guide/minidump.md b/docs/en/developer-guide/minidump.md index aef0a1fb41..47468ebd99 100644 --- a/docs/en/developer-guide/minidump.md +++ b/docs/en/developer-guide/minidump.md @@ -24,7 +24,9 @@ specific language governing permissions and limitations under the License. --> -# Minidump +# Minidump(removed) + +> Minidump has been removed, it's useless in real online environment and instead introduces additional bugs Minidump is a file format defined by Microsoft for reporting errors after program crashes. It includes thread information, register information, call stack information, etc. at the time of the crash, which helps developers quickly locate the problem. diff --git a/docs/zh-CN/developer-guide/minidump.md b/docs/zh-CN/developer-guide/minidump.md index df58b073ef..ca71bc45b5 100644 --- a/docs/zh-CN/developer-guide/minidump.md +++ b/docs/zh-CN/developer-guide/minidump.md @@ -24,7 +24,9 @@ specific language governing permissions and limitations under the License. --> -# Minidump +# Minidump(removed) + +> Minidump 已经被移除,它在实际线上环境中没有用处,反而会引入额外的错误。 Minidump 是微软定义的一种用于程序崩溃后错误上报的文件格式。其中包括了崩溃时的线程信息、寄存器信息、调用栈信息等等,这有助于开发人员快速定位问题。 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org