This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new c2732d4f30c [fix](memory) Fix jemalloc hook deadlock at BE start
(#44009)
c2732d4f30c is described below
commit c2732d4f30c6388edbee3c830a1ce8388f0cd698
Author: Xinyi Zou <[email protected]>
AuthorDate: Sat Nov 16 10:06:34 2024 +0800
[fix](memory) Fix jemalloc hook deadlock at BE start (#44009)
It should be caused by the third-party library, but in any case, this
fix should be possible.
```
#0 0x00007f738432318c in __lll_lock_wait_private () from /lib64/libc.so.6
#1 0x00007f73843505ed in __internal_atexit () from /lib64/libc.so.6
#2 0x0000563f6a54db30 in malloc ()
#3 0x0000563f74e82b08 in operator new(unsigned long) ()
#4 0x0000563f6a6144bd in doris::ThreadContextPtr::ThreadContextPtr() ()
#5 0x0000563f6a54e21c in doris_calloc ()
#6 0x00007f7384350557 in __new_exitfn () from /lib64/libc.so.6
#7 0x00007f73843505fc in __internal_atexit () from /lib64/libc.so.6
#8 0x0000563f72c79c03 in ?? ()
#9 0x0000563f74e3b5fd in __libc_csu_init ()
#10 0x00007f7384339d18 in __libc_start_main () from /lib64/libc.so.6
#11 0x0000563f69ae302a in _start ()
```
---
be/src/common/daemon.cpp | 1 +
be/src/common/daemon.h | 1 +
be/src/runtime/thread_context.h | 9 +++++----
be/src/service/doris_main.cpp | 2 ++
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/be/src/common/daemon.cpp b/be/src/common/daemon.cpp
index f91aec88f59..98315609865 100644
--- a/be/src/common/daemon.cpp
+++ b/be/src/common/daemon.cpp
@@ -409,6 +409,7 @@ static void init_doris_metrics(const
std::vector<StorePath>& store_paths) {
void signal_handler(int signal) {
if (signal == SIGINT || signal == SIGTERM) {
k_doris_exit = true;
+ k_doris_start = false;
LOG(INFO) << "doris start to exit";
}
}
diff --git a/be/src/common/daemon.h b/be/src/common/daemon.h
index 5ac9abbe2b1..36d2ca0813a 100644
--- a/be/src/common/daemon.h
+++ b/be/src/common/daemon.h
@@ -27,6 +27,7 @@ namespace doris {
struct StorePath;
inline bool k_doris_exit = false;
+inline bool k_doris_start = false;
class Daemon {
public:
diff --git a/be/src/runtime/thread_context.h b/be/src/runtime/thread_context.h
index bbfd1a02979..23ee742b867 100644
--- a/be/src/runtime/thread_context.h
+++ b/be/src/runtime/thread_context.h
@@ -100,6 +100,7 @@ class MemTracker;
class RuntimeState;
extern bool k_doris_exit;
+extern bool k_doris_start;
extern bthread_key_t btls_key;
// Using gcc11 compiles thread_local variable on lower versions of GLIBC will
report an error,
@@ -388,17 +389,17 @@ private:
// which is different from the previous behavior.
#define CONSUME_MEM_TRACKER(size)
\
do {
\
- if (doris::thread_context_ptr.init) {
\
+ if (doris::k_doris_start && doris::thread_context_ptr.init) {
\
doris::thread_context()->consume_memory(size);
\
- } else if (doris::ExecEnv::GetInstance()->initialized()) {
\
+ } else if (doris::k_doris_start &&
doris::ExecEnv::GetInstance()->initialized()) { \
doris::ExecEnv::GetInstance()->orphan_mem_tracker_raw()->consume_no_update_peak(size);
\
}
\
} while (0)
#define RELEASE_MEM_TRACKER(size)
\
do {
\
- if (doris::thread_context_ptr.init) {
\
+ if (doris::k_doris_start && doris::thread_context_ptr.init) {
\
doris::thread_context()->consume_memory(-size);
\
- } else if (doris::ExecEnv::GetInstance()->initialized()) {
\
+ } else if (doris::k_doris_start &&
doris::ExecEnv::GetInstance()->initialized()) { \
doris::ExecEnv::GetInstance()->orphan_mem_tracker_raw()->consume_no_update_peak(
\
-size);
\
}
\
diff --git a/be/src/service/doris_main.cpp b/be/src/service/doris_main.cpp
index 3b6cf2969cf..643ba0837b9 100644
--- a/be/src/service/doris_main.cpp
+++ b/be/src/service/doris_main.cpp
@@ -82,6 +82,7 @@ int __llvm_profile_write_file();
namespace doris {
extern bool k_doris_exit;
+extern bool k_doris_start;
static void thrift_output(const char* x) {
LOG(WARNING) << "thrift internal message: " << x;
@@ -463,6 +464,7 @@ int main(int argc, char** argv) {
// init exec env
auto exec_env = doris::ExecEnv::GetInstance();
+ doris::k_doris_start = true;
doris::ExecEnv::init(exec_env, paths);
doris::TabletSchemaCache::create_global_schema_cache();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]