fix tenant thread name issue

This commit is contained in:
ly0
2021-09-26 14:44:06 +08:00
committed by wangzelin.wzl
parent bb004431db
commit f6d7fbdeaf
2 changed files with 4 additions and 4 deletions

View File

@ -117,6 +117,7 @@ void ObThWorker::activate()
run_cond_.signal(); run_cond_.signal();
} }
static __thread uint64_t serving_tenant_id = 0;
void ObThWorker::wait_active() void ObThWorker::wait_active()
{ {
bool has_reset_pm = false; bool has_reset_pm = false;
@ -132,6 +133,8 @@ void ObThWorker::wait_active()
has_reset_pm = true; has_reset_pm = true;
} }
waiting_active_ = true; waiting_active_ = true;
lib::set_thread_name("OMT_FREE_", NULL == tenant_ ? 0 : tenant_->id());
serving_tenant_id = 0;
IGNORE_RETURN run_cond_.wait(); IGNORE_RETURN run_cond_.wait();
waiting_active_ = false; waiting_active_ = false;
} }
@ -342,19 +345,17 @@ void ObThWorker::set_th_worker_thread_name(uint64_t tenant_id)
// fix compile issue // fix compile issue
UNUSED(tenant_id); UNUSED(tenant_id);
static __thread uint64_t serving_tenant_id = 0;
char buf[32]; char buf[32];
if (serving_tenant_id != tenant_->id()) { if (serving_tenant_id != tenant_->id()) {
serving_tenant_id = tenant_->id();
snprintf(buf, 32, "TNT_L%d_", get_worker_level()); snprintf(buf, 32, "TNT_L%d_", get_worker_level());
lib::set_thread_name(buf, tenant_->id()); lib::set_thread_name(buf, tenant_->id());
serving_tenant_id = tenant_->id();
} }
} }
void ObThWorker::worker(int64_t& tenant_id, int64_t& req_recv_timestamp, int32_t& worker_level) void ObThWorker::worker(int64_t& tenant_id, int64_t& req_recv_timestamp, int32_t& worker_level)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
lib::set_thread_name("OMT_FREE", ObWorker::get_tidx());
Worker::self_ = this; Worker::self_ = this;
ObWorker::self_ = this; ObWorker::self_ = this;
int64_t wait_start_time = 0; int64_t wait_start_time = 0;

View File

@ -185,7 +185,6 @@ inline void ObThWorker::reset()
ws_ = WStatus::STOPPED; ws_ = WStatus::STOPPED;
active_ = false; active_ = false;
unset_tidx(); unset_tidx();
lib::set_thread_name("OMT_FREE", ObWorker::get_tidx());
} }
inline void ObThWorker::set_tenant(ObTenant* tenant) inline void ObThWorker::set_tenant(ObTenant* tenant)