[CP] fix error log when kill -15

This commit is contained in:
nroskill
2024-02-07 09:02:07 +00:00
committed by ob-robot
parent b800d07f1c
commit 160ff54fe6
2 changed files with 11 additions and 9 deletions

View File

@ -37,7 +37,7 @@ int ob_pthread_create(void **ptr, void *(*start_routine) (void *), void *arg)
OB_DELETE(ObPThread, SET_USE_500("PThread"), thread);
}
} else {
*ptr = thread;
ATOMIC_STORE(ptr, thread);
OB_LOG(INFO, "ob_pthread_create succeed", KP(thread));
}
return ret;

View File

@ -869,7 +869,7 @@ void ObTenant::sleep_and_warn(ObTenant* tenant)
{
ob_usleep(10_ms);
const int64_t ts = ObTimeUtility::current_time() - tenant->stopped_;
if (ts >= 3_min && TC_REACH_TIME_INTERVAL(3_min)) {
if (ts >= 3L * 60 * 1000 * 1000 && TC_REACH_TIME_INTERVAL(3L * 60 * 1000 * 1000)) {
LOG_ERROR_RET(OB_SUCCESS, "tenant destructed for too long time.", K_(tenant->id), K(ts));
}
}
@ -942,16 +942,18 @@ void* ObTenant::wait(void* t)
int ObTenant::try_wait()
{
int ret = OB_SUCCESS;
if (nullptr == gc_thread_) {
if (has_created_) {
LOG_WARN("try_wait after wait successfully", K(id_), K(wait_mtl_finished_));
if (OB_ISNULL(ATOMIC_LOAD(&gc_thread_))) {
if (!ATOMIC_BCAS(&has_created_, false, true)) {
// try_wait should not return OB_SUCCESS here, but we returned OB_SUCCESS for safety quit in main thread.
// ret = OB_ERR_UNEXPECTED;
LOG_ERROR("try_wait again after wait successfully, there may be `kill -15`", K(id_), K(wait_mtl_finished_));
} else {
// it may takes too much time for killing session after remove_tenant, we should recalculate.
ATOMIC_STORE(&stopped_, ObTimeUtility::current_time());
ATOMIC_STORE(&stopped_, ObTimeUtility::current_time()); // update, it is not 0 before here.
if (OB_FAIL(ob_pthread_create(&gc_thread_, wait, this))) {
ATOMIC_STORE(&has_created_, false);
LOG_ERROR("tenant gc thread create failed", K(ret), K(errno), K(id_));
} else {
has_created_ = true;
ret = OB_EAGAIN;
LOG_INFO("tenant pthread_create gc thread successfully", K(id_), K(gc_thread_));
}
@ -960,12 +962,12 @@ int ObTenant::try_wait()
if (OB_FAIL(ob_pthread_tryjoin_np(gc_thread_))) {
LOG_WARN("tenant pthread_tryjoin_np failed", K(errno), K(id_));
} else {
gc_thread_ = nullptr; // avoid try_wait again after wait success
ATOMIC_STORE(&gc_thread_, nullptr); // avoid try_wait again after wait success
LOG_INFO("tenant pthread_tryjoin_np successfully", K(id_));
}
const int64_t ts = ObTimeUtility::current_time() - stopped_;
// only warn for one time in all tenant.
if (ts >= 3_min && REACH_TIME_INTERVAL(3_min)) {
if (ts >= 3L * 60 * 1000 * 1000 && REACH_TIME_INTERVAL(3L * 60 * 1000 * 1000)) {
LOG_ERROR_RET(OB_SUCCESS, "tenant destructed for too long time.", K_(id), K(ts));
}
}