This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 0376ca17f3 [Enhancement] Remove minidump (#9894)
0376ca17f3 is described below

commit 0376ca17f3e88fbc8c23ab16aa4668ec1acb3fbc
Author: Xinyi Zou <[email protected]>
AuthorDate: Wed Jun 1 08:04:24 2022 +0800

    [Enhancement] Remove minidump (#9894)
---
 be/CMakeLists.txt                      |   5 -
 be/src/common/config.h                 |  15 ---
 be/src/runtime/CMakeLists.txt          |   1 -
 be/src/runtime/minidump.cpp            | 172 ---------------------------------
 be/src/runtime/minidump.h              |  64 ------------
 be/src/service/doris_main.cpp          |  11 ---
 be/test/CMakeLists.txt                 |   1 -
 be/test/runtime/minidump_test.cpp      |  74 --------------
 docs/en/developer-guide/minidump.md    |   4 +-
 docs/en/faq/install-faq.md             |   2 +-
 docs/zh-CN/developer-guide/minidump.md |   4 +-
 docs/zh-CN/faq/install-faq.md          |   2 +-
 12 files changed, 8 insertions(+), 347 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 6079cfa5fc..480a3c6e46 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -330,9 +330,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)
@@ -516,7 +513,6 @@ include_directories(
     ${GENSRC_DIR}/
     ${THIRDPARTY_DIR}/include
     ${GPERFTOOLS_HOME}/include
-    ${THIRDPARTY_DIR}/include/breakpad/
 )
 
 if (BUILD_JAVA_UDF)
@@ -632,7 +628,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 6958a73e0d..8205ac2537 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -690,21 +690,6 @@ CONF_mInt32(segment_cache_capacity, "1000000");
 // s3 config
 CONF_mInt32(max_remote_storage_count, "10");
 
-// 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,
 // and the valid values are: 0.9.0, 0.8.2, 0.8.1, 0.8.0.
diff --git a/be/src/runtime/CMakeLists.txt b/be/src/runtime/CMakeLists.txt
index 414f4057c5..7692ae933f 100644
--- a/be/src/runtime/CMakeLists.txt
+++ b/be/src/runtime/CMakeLists.txt
@@ -110,7 +110,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 32d399d21d..0000000000
--- a/be/src/runtime/minidump.cpp
+++ /dev/null
@@ -1,172 +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 "client/linux/handler/exception_handler.h"
-#include "common/config.h"
-#include "env/env.h"
-#include "util/file_utils.h"
-#include "util/string_util.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 MinidumpFileStat {
-    std::string abs_path;
-    time_t create_time;
-
-    MinidumpFileStat(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 (config::disable_minidump || _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<MinidumpFileStat> 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 MinidumpFileStat& f1, const MinidumpFileStat& 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 026dbc1e01..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 cf486b2c98..3230de6e65 100644
--- a/be/src/service/doris_main.cpp
+++ b/be/src/service/doris_main.cpp
@@ -51,7 +51,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"
@@ -457,15 +456,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);
-    }
-
 #ifdef LIBJVM
     // 6. init jni
     status = doris::JniUtil::Init();
@@ -499,7 +489,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/CMakeLists.txt b/be/test/CMakeLists.txt
index 48d37e56a1..9c7a9190f0 100644
--- a/be/test/CMakeLists.txt
+++ b/be/test/CMakeLists.txt
@@ -227,7 +227,6 @@ set(RUNTIME_TEST_FILES
     # runtime/buffered_block_mgr2_test.cpp
     # runtime/buffered_tuple_stream2_test.cpp
     # runtime/export_task_mgr_test.cpp
-    # runtime/minidump_test.cpp
     runtime/mem_pool_test.cpp
     runtime/string_buffer_test.cpp
     runtime/decimalv2_value_test.cpp
diff --git a/be/test/runtime/minidump_test.cpp 
b/be/test/runtime/minidump_test.cpp
deleted file mode 100644
index c37b8a3ea5..0000000000
--- a/be/test/runtime/minidump_test.cpp
+++ /dev/null
@@ -1,74 +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 <gtest/gtest.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
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/en/faq/install-faq.md b/docs/en/faq/install-faq.md
index 1a942b0eb6..0c291f40a7 100644
--- a/docs/en/faq/install-faq.md
+++ b/docs/en/faq/install-faq.md
@@ -153,7 +153,7 @@ In many cases, we need to troubleshoot problems through 
logs. The format and vie
 
       Logs starting with F are Fatal logs. For example, F0916 , indicating the 
Fatal log on September 16th. Fatal logs usually indicate a program assertion 
error, and an assertion error will directly cause the process to exit 
(indicating a bug in the program). Welcome to the WeChat group, github 
discussion or dev mail group for help.
 
-   4. Minidump
+   4. Minidump(removed)
 
       Mindump is a function added after Doris version 0.15. For details, 
please refer to 
[document](https://doris.apache.org/zh-CN/developer-guide/minidump.html).
 
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 是微软定义的一种用于程序崩溃后错误上报的文件格式。其中包括了崩溃时的线程信息、寄存器信息、调用栈信息等等,这有助于开发人员快速定位问题。
 
diff --git a/docs/zh-CN/faq/install-faq.md b/docs/zh-CN/faq/install-faq.md
index 71a5556d13..27d848937a 100644
--- a/docs/zh-CN/faq/install-faq.md
+++ b/docs/zh-CN/faq/install-faq.md
@@ -153,7 +153,7 @@ Observer 角色和这个单词的含义一样,仅仅作为观察者来同步
 
       F开头的日志是 Fatal 日志。如 F0916 
,表示9月16号的Fatal日志。Fatal日志通常表示程序断言错误,断言错误会直接导致进程退出(说明程序出现了Bug)。欢迎前往微信群、github 
discussion 或dev邮件组寻求帮助。
 
-   4. Minidump
+   4. Minidump(removed)
 
       Mindump 是 Doris 0.15 
版本之后加入的功能,具体可参阅[文档](https://doris.apache.org/zh-CN/developer-guide/minidump.html)。
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to