summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2024-06-14 18:49:44 +0300
committerGitHub <noreply@github.com>2024-06-14 18:49:44 +0300
commit7450f4d7a121a7243ae5e3b4534a73b556eba2ed (patch)
tree374ea3b6acd238e4277e1809d98dc9c1560ee651 /src
parent03b138974eee7a17ece5164842581d233f774a7b (diff)
Improve ml thread termination during agent shutdown (#17889)
* Signal ML to terminate first without waiting for the threads to terminate Add additional check if we need to stop within the per host ML processing * Check for SERVICE_COLLECTORS running for the PREDICTION thread * Function void param * Function void param
Diffstat (limited to 'src')
-rw-r--r--src/ml/ml.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ml/ml.cc b/src/ml/ml.cc
index 88de840595..7ecdce4180 100644
--- a/src/ml/ml.cc
+++ b/src/ml/ml.cc
@@ -1220,7 +1220,7 @@ ml_detect_main(void *arg)
heartbeat_t hb;
heartbeat_init(&hb);
- while (!Cfg.detection_stop) {
+ while (!Cfg.detection_stop && service_running(SERVICE_COLLECTORS)) {
worker_is_idle();
heartbeat_next(&hb, USEC_PER_SEC);
@@ -1230,6 +1230,9 @@ ml_detect_main(void *arg)
if (!rh->ml_host)
continue;
+ if (!service_running(SERVICE_COLLECTORS))
+ break;
+
ml_host_detect_once((ml_host_t *) rh->ml_host);
}
rrd_rdunlock();
@@ -1266,6 +1269,7 @@ ml_detect_main(void *arg)
}
}
}
+ Cfg.training_stop = true;
return NULL;
}