@cryptotaxi247 / netdata-1 / commits / c5eb91bad

Fix queue removed alerts (#11996)

* delay queueing removed alerts * parenthesis * remove debug

Emmanuel Vasilakis committed Jan 19, 2022 at 19:52 UTC c5eb91bad10ea8079c6fa630de54b38762abebaf
2 files changed +20 -11
database/sqlite/sqlite_aclk_alert.c
+2
@@ -607,6 +607,8 @@ void sql_process_queue_removed_alerts_to_aclk(struct aclk_database_worker_config
607
608 db_execute(buffer_tostring(sql));
609
610 + log_access("AC [%s (%s)]: Queued removed alerts.", wc->node_id, wc->host ? wc->host->hostname : "N/A");
611 +
612 buffer_free(sql);
613 #endif
614 return;
health/health.c
+18 -11
@@ -676,6 +676,9 @@ void *health_main(void *ptr) {
676 rrdcalc_labels_unlink();
677
678 unsigned int loop = 0;
679 +#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
680 + unsigned int marked_aclk_reload_loop = 0;
681 +#endif
682 while(!netdata_exit) {
683 loop++;
684 debug(D_HEALTH, "Health monitoring iteration no %u started", loop);
@@ -702,6 +705,11 @@ void *health_main(void *ptr) {
705 }
706 }
707
708 +#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
709 + if (aclk_alert_reloaded && !marked_aclk_reload_loop)
710 + marked_aclk_reload_loop = loop;
711 +#endif
712 +
713 rrd_rdlock();
714
715 RRDHOST *host;
@@ -1043,14 +1051,6 @@ void *health_main(void *ptr) {
1051 rrdhost_unlock(host);
1052 }
1053
1046 -#ifdef ENABLE_ACLK
1047 -#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1048 - if (netdata_cloud_setting && unlikely(aclk_alert_reloaded) && loop > 2) {
1049 - sql_queue_removed_alerts_to_aclk(host);
1050 - }
1051 -#endif
1052 -#endif
1053 -
1054 if (unlikely(netdata_exit))
1055 break;
1056
@@ -1075,9 +1075,16 @@ void *health_main(void *ptr) {
1075 health_alarm_wait_for_execution(ae);
1076 }
1077
1078 -#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1079 - if (netdata_cloud_setting && unlikely(aclk_alert_reloaded))
1080 - aclk_alert_reloaded = 0;
1078 +#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1079 + if (netdata_cloud_setting && unlikely(aclk_alert_reloaded) && loop > (marked_aclk_reload_loop + 2)) {
1080 + rrdhost_foreach_read(host) {
1081 + if (unlikely(!host->health_enabled))
1082 + continue;
1083 + sql_queue_removed_alerts_to_aclk(host);
1084 + }
1085 + aclk_alert_reloaded = 0;
1086 + marked_aclk_reload_loop = 0;
1087 + }
1088 #endif
1089
1090 rrd_unlock();