diff options
| author | yangwei <[email protected]> | 2023-12-25 14:40:35 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2023-12-25 14:40:35 +0800 |
| commit | 382f15bd1b7ddc220f08fa0b275a8566603e8ed1 (patch) | |
| tree | 930858da9c0c81e77d0f3588a9e87b2698e707eb | |
| parent | cc0ef6e12ce0c88152f294a174637c18b8f3f577 (diff) | |
✨ feat(overload protection): 单核CPU超过99%,工作线程输出调用堆栈
| -rw-r--r-- | src/support/cpu_limit/cpu_limit.c | 7 | ||||
| -rw-r--r-- | src/timer/sapp_timer.c | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/support/cpu_limit/cpu_limit.c b/src/support/cpu_limit/cpu_limit.c index cbfb5d0..3ea9203 100644 --- a/src/support/cpu_limit/cpu_limit.c +++ b/src/support/cpu_limit/cpu_limit.c @@ -266,6 +266,8 @@ static void cl_analysis_observe_state(cpu_limit_inner_t *h, int tid, cpul_mthrea return ; } +#include "sapp_declaration.h" + static void cl_analysis(cpu_limit_inner_t *h) { cpul_mthread_stat_t *this_stat; @@ -276,6 +278,11 @@ static void cl_analysis(cpu_limit_inner_t *h) if(this_stat->realtime_res_val >= h->user_trigger_value){//超最高限制阈值 cl_analysis_reduce_state(h, tid, this_stat); + if(this_stat->realtime_res_val >= 99.0 && MESA_handle_runtime_log_level_enabled(ABBR_PROCESS_LATENCY_LOG_HANDLE, RLOG_LV_FATAL)) + { + sapp_process_latency_log(RLOG_LV_FATAL, "cpu_limit usage over 99%%, send SIGUSR2 to thread:%d, tid:%d", tid, sapp_global_val->individual_fixed.thread_obtain_id[tid]); + pthread_kill(sapp_global_val->individual_fixed.thread_obtain_id[tid], SIGUSR2); + } }else{ cl_analysis_observe_state(h, tid, this_stat); /* 可能是从没有过攻击, 可能是刚从攻击状态bypass之后恢复过来 */ } diff --git a/src/timer/sapp_timer.c b/src/timer/sapp_timer.c index 6d70f33..32666f9 100644 --- a/src/timer/sapp_timer.c +++ b/src/timer/sapp_timer.c @@ -462,6 +462,7 @@ static void sapp_watch_dog(void) sapp_runtime_log(RLOG_LV_FATAL, "##### detect deadlock in PID:%ld, at timestamp:%ld, thread index:%d, TID(LWP):%u, sd_notify_enable:%d, deadlock_detected:%d, deadlock_cnt:%d #####", getpid(), ABBR_CURRENT_TIME, thread_index, sapp_global_val->individual_fixed.thread_tid[thread_index], sd_notify_enable, deadlock_detected, deadlock_cnt); } + sapp_process_latency_log(RLOG_LV_FATAL, "sapp_watch_dog detect deadlock at timestamp:%ld, send SIGUSR2 to tid:%d", ABBR_CURRENT_TIME, thread_index); pthread_kill(sapp_global_val->individual_fixed.thread_obtain_id[thread_index], SIGUSR2); break; |
