fix ObRsReentrantThread::check_alert about thread_id

This commit is contained in:
obdev
2023-05-08 04:11:53 +00:00
committed by ob-robot
parent 8331f2f878
commit aed19000b4
2 changed files with 6 additions and 3 deletions

View File

@ -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;

View File

@ -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