From aed19000b4fe6b599de1ef8ff8fa31953b746d46 Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 8 May 2023 04:11:53 +0000 Subject: [PATCH] fix ObRsReentrantThread::check_alert about thread_id --- src/rootserver/ob_rs_reentrant_thread.cpp | 6 +++--- src/rootserver/ob_rs_reentrant_thread.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rootserver/ob_rs_reentrant_thread.cpp b/src/rootserver/ob_rs_reentrant_thread.cpp index 353a9e3ad5..eef883cafb 100644 --- a/src/rootserver/ob_rs_reentrant_thread.cpp +++ b/src/rootserver/ob_rs_reentrant_thread.cpp @@ -25,11 +25,11 @@ namespace rootserver CheckThreadSet ObRsReentrantThread::check_thread_set_; ObRsReentrantThread::ObRsReentrantThread() - :last_run_timestamp_(-1) + :last_run_timestamp_(-1), thread_id_(-1) {} ObRsReentrantThread::ObRsReentrantThread(bool need_check) - :last_run_timestamp_(need_check ? 0 : -1) + :last_run_timestamp_(need_check ? 0 : -1), thread_id_(-1) {} ObRsReentrantThread::~ObRsReentrantThread() @@ -126,7 +126,7 @@ int64_t ObRsReentrantThread::get_last_run_timestamp() const void ObRsReentrantThread::check_alert(const ObRsReentrantThread &thread) { if (thread.need_monitor_check()) { - const pid_t thread_id = syscall(__NR_gettid); // only called by thread self + const pid_t thread_id = thread.get_thread_id(); const char *thread_name = thread.get_thread_name(); int64_t last_run_timestamp = thread.get_last_run_timestamp(); int64_t last_run_interval = ObTimeUtility::current_time() - last_run_timestamp; diff --git a/src/rootserver/ob_rs_reentrant_thread.h b/src/rootserver/ob_rs_reentrant_thread.h index e5f5a99b73..868fb1488d 100644 --- a/src/rootserver/ob_rs_reentrant_thread.h +++ b/src/rootserver/ob_rs_reentrant_thread.h @@ -33,6 +33,7 @@ public: virtual void run2() override { int ret = common::OB_SUCCESS; + thread_id_ = (pid_t)syscall(__NR_gettid); // only called by thread self run3(); } virtual void run3() = 0; @@ -61,6 +62,7 @@ public: void stop(); void wait(); void reset_last_run_timestamp() { ATOMIC_STORE(&last_run_timestamp_, 0); } + pid_t get_thread_id() const { return thread_id_; } TO_STRING_KV("name", get_thread_name()); private: @@ -68,6 +70,7 @@ private: // =0 :pause check thread; // =-1 :close check thread; int64_t last_run_timestamp_; + pid_t thread_id_; #ifdef ERRSIM //for obtest static const int64_t MAX_THREAD_SCHEDULE_OVERRUN_TIME = 5LL * 1000LL * 1000LL; #else