Add worker for alert queue processing (#19498)
* Add worker for alert queue processing * Add a worker job to monitor wait for execution Make sure to worker_idle() after every host processing
Stelios Fragkakis committed
Jan 27, 2025 at 21:09 UTC
34a06470f539e34753cf5405ff75d20c412fe0cd
1 file changed
+10
-2
src/health/health_event_loop.c
+10
-2
@@ -12,8 +12,10 @@
12
#define WORKER_HEALTH_JOB_CRITICAL_EVAL 5
13
#define WORKER_HEALTH_JOB_ALARM_LOG_ENTRY 6
14
#define WORKER_HEALTH_JOB_ALARM_LOG_PROCESS 7
15
-#define WORKER_HEALTH_JOB_DELAYED_INIT_RRDSET 8
16
-#define WORKER_HEALTH_JOB_DELAYED_INIT_RRDDIM 9
15
+#define WORKER_HEALTH_JOB_ALARM_LOG_QUEUE 8
16
+#define WORKER_HEALTH_JOB_WAIT_EXEC 9
17
+#define WORKER_HEALTH_JOB_DELAYED_INIT_RRDSET 10
18
+#define WORKER_HEALTH_JOB_DELAYED_INIT_RRDDIM 11
19
20
#if WORKER_UTILIZATION_MAX_JOB_TYPES < 10
21
#error WORKER_UTILIZATION_MAX_JOB_TYPES has to be at least 10
@@ -637,10 +639,12 @@ static void health_event_loop_for_host(RRDHOST *host, bool apply_hibernation_del
639
wc->send_snapshot = 2;
640
rrdhost_flag_set(host, RRDHOST_FLAG_ACLK_STREAM_ALERTS);
641
} else {
642
+ worker_is_busy(WORKER_HEALTH_JOB_ALARM_LOG_QUEUE);
643
if (process_alert_pending_queue(host))
644
rrdhost_flag_set(host, RRDHOST_FLAG_ACLK_STREAM_ALERTS);
645
}
646
}
647
+ worker_is_idle();
648
}
649
650
__thread bool is_health_thread = false;
@@ -693,7 +697,9 @@ static void health_event_loop(void) {
697
break;
698
699
// wait for all notifications to finish before allowing health to be cleaned up
700
+ worker_is_busy(WORKER_HEALTH_JOB_WAIT_EXEC);
701
wait_for_all_notifications_to_finish_before_allowing_health_to_be_cleaned_up();
702
+ worker_is_idle();
703
704
health_sleep(next_run, loop);
705
} // forever
@@ -721,6 +727,8 @@ void *health_main(void *ptr) {
727
worker_register_job_name(WORKER_HEALTH_JOB_CRITICAL_EVAL, "critical eval");
728
worker_register_job_name(WORKER_HEALTH_JOB_ALARM_LOG_ENTRY, "alert log entry");
729
worker_register_job_name(WORKER_HEALTH_JOB_ALARM_LOG_PROCESS, "alert log process");
730
+ worker_register_job_name(WORKER_HEALTH_JOB_ALARM_LOG_QUEUE, "alert log queue");
731
+ worker_register_job_name(WORKER_HEALTH_JOB_WAIT_EXEC, "alert wait exec");
732
worker_register_job_name(WORKER_HEALTH_JOB_DELAYED_INIT_RRDSET, "rrdset init");
733
worker_register_job_name(WORKER_HEALTH_JOB_DELAYED_INIT_RRDDIM, "rrddim init");
734