From d22fbaf1735584d3b1ae76e5b1c1b8de5473721c Mon Sep 17 00:00:00 2001 From: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:34:55 +0200 Subject: [PATCH 1/2] Health transition saving optimization (#19245) Choose health transition save mode --- src/health/health.h | 4 ++-- src/health/health_event_loop.c | 4 ++-- src/health/health_log.c | 13 ++++++++----- src/health/health_notifications.c | 4 ++-- src/health/rrdcalc.c | 5 ++--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/health/health.h b/src/health/health.h index cdd089623f54af..b6790b4d5852f7 100644 --- a/src/health/health.h +++ b/src/health/health.h @@ -58,7 +58,7 @@ void health_api_v1_chart_variables2json(RRDSET *st, BUFFER *wb); void health_api_v1_chart_custom_variables2json(RRDSET *st, BUFFER *buf); int health_alarm_log_open(RRDHOST *host); -void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae); +void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae, bool async); void health_alarm_log_load(RRDHOST *host); ALARM_ENTRY* health_create_alarm_entry( @@ -73,7 +73,7 @@ ALARM_ENTRY* health_create_alarm_entry( int delay, HEALTH_ENTRY_FLAGS flags); -void health_alarm_log_add_entry(RRDHOST *host, ALARM_ENTRY *ae); +void health_alarm_log_add_entry(RRDHOST *host, ALARM_ENTRY *ae, bool async); const char *health_user_config_dir(void); const char *health_stock_config_dir(void); diff --git a/src/health/health_event_loop.c b/src/health/health_event_loop.c index d20d99d35d9c16..2b6d2529da0103 100644 --- a/src/health/health_event_loop.c +++ b/src/health/health_event_loop.c @@ -303,7 +303,7 @@ static void health_event_loop_for_host(RRDHOST *host, bool apply_hibernation_del if (ae) { health_log_alert(host, ae); - health_alarm_log_add_entry(host, ae); + health_alarm_log_add_entry(host, ae, false); rc->old_status = rc->status; rc->status = RRDCALC_STATUS_REMOVED; rc->last_status_change = now_tmp; @@ -506,7 +506,7 @@ static void health_event_loop_for_host(RRDHOST *host, bool apply_hibernation_del ); health_log_alert(host, ae); - health_alarm_log_add_entry(host, ae); + health_alarm_log_add_entry(host, ae, false); nd_log(NDLS_DAEMON, NDLP_DEBUG, "[%s]: Alert event for [%s.%s], value [%s], status [%s].", diff --git a/src/health/health_log.c b/src/health/health_log.c index d5f8b9b9acf288..e8c66f0402be3b 100644 --- a/src/health/health_log.c +++ b/src/health/health_log.c @@ -5,9 +5,12 @@ // ---------------------------------------------------------------------------- -inline void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae) +inline void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae, bool async) { - metadata_queue_ae_save(host, ae); + if (async) + metadata_queue_ae_save(host, ae); + else + sql_health_alarm_log_save(host, ae); } void health_log_alert_transition_with_trace(RRDHOST *host, ALARM_ENTRY *ae, int line, const char *file, const char *function) { @@ -168,7 +171,7 @@ inline ALARM_ENTRY* health_create_alarm_entry( return ae; } -inline void health_alarm_log_add_entry(RRDHOST *host, ALARM_ENTRY *ae) +inline void health_alarm_log_add_entry(RRDHOST *host, ALARM_ENTRY *ae, bool async) { netdata_log_debug(D_HEALTH, "Health adding alarm log entry with id: %u", ae->unique_id); @@ -195,7 +198,7 @@ inline void health_alarm_log_add_entry(RRDHOST *host, ALARM_ENTRY *ae) (t->old_status == RRDCALC_STATUS_WARNING || t->old_status == RRDCALC_STATUS_CRITICAL)) ae->non_clear_duration += t->non_clear_duration; - health_alarm_log_save(host, t); + health_alarm_log_save(host, t, async); } // no need to continue @@ -204,7 +207,7 @@ inline void health_alarm_log_add_entry(RRDHOST *host, ALARM_ENTRY *ae) } rw_spinlock_read_unlock(&host->health_log.spinlock); - health_alarm_log_save(host, ae); + health_alarm_log_save(host, ae, async); } inline void health_alarm_log_free_one_nochecks_nounlink(ALARM_ENTRY *ae) { diff --git a/src/health/health_notifications.c b/src/health/health_notifications.c index 2b11b5bf2f3cb2..13e9ef8e4f84ec 100644 --- a/src/health/health_notifications.c +++ b/src/health/health_notifications.c @@ -485,7 +485,7 @@ void health_send_notification(RRDHOST *host, ALARM_ENTRY *ae, struct health_rais else netdata_log_error("Failed to execute alarm notification"); - health_alarm_log_save(host, ae); + health_alarm_log_save(host, ae, false); } else netdata_log_error("Failed to format command arguments"); @@ -497,7 +497,7 @@ void health_send_notification(RRDHOST *host, ALARM_ENTRY *ae, struct health_rais return; //health_alarm_wait_for_execution done: - health_alarm_log_save(host, ae); + health_alarm_log_save(host, ae, false); } bool health_alarm_log_get_global_id_and_transition_id_for_rrdcalc(RRDCALC *rc, usec_t *global_id, nd_uuid_t *transitions_id) { diff --git a/src/health/rrdcalc.c b/src/health/rrdcalc.c index 645bab24a73f25..cd499b8e2b8ba9 100644 --- a/src/health/rrdcalc.c +++ b/src/health/rrdcalc.c @@ -243,9 +243,8 @@ static void rrdcalc_link_to_rrdset(RRDCALC *rc) { rrdcalc_isrepeating(rc)?HEALTH_ENTRY_FLAG_IS_REPEATING:0); health_log_alert(host, ae); - health_alarm_log_add_entry(host, ae); + health_alarm_log_add_entry(host, ae, false); rrdset_flag_set(st, RRDSET_FLAG_HAS_RRDCALC_LINKED); - } static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) { @@ -277,7 +276,7 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) { 0); health_log_alert(host, ae); - health_alarm_log_add_entry(host, ae); + health_alarm_log_add_entry(host, ae, true); } } From 6dcce75e6da4dfecca73b242a261a8d895a6b687 Mon Sep 17 00:00:00 2001 From: netdatabot Date: Thu, 19 Dec 2024 00:22:28 +0000 Subject: [PATCH 2/2] [ci skip] Update changelog and version for nightly build: v2.0.0-265-nightly. --- CHANGELOG.md | 9 ++++----- packaging/version | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d7e4868e49be2..1fafb7c066e03a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ **Merged pull requests:** +- chore\(aclk/mqtt\): remove client\_id len check [\#19247](https://github.com/netdata/netdata/pull/19247) ([ilyam8](https://github.com/ilyam8)) +- chore\(go.d\): simplify cli is help [\#19246](https://github.com/netdata/netdata/pull/19246) ([ilyam8](https://github.com/ilyam8)) +- Health transition saving optimization [\#19245](https://github.com/netdata/netdata/pull/19245) ([stelfrag](https://github.com/stelfrag)) +- Avoid blocking waiting for an event during shutdown [\#19244](https://github.com/netdata/netdata/pull/19244) ([stelfrag](https://github.com/stelfrag)) - Do not call finalize on shutdown [\#19241](https://github.com/netdata/netdata/pull/19241) ([stelfrag](https://github.com/stelfrag)) - fix the renamed function under windows [\#19240](https://github.com/netdata/netdata/pull/19240) ([ktsaou](https://github.com/ktsaou)) - update netdata internal metrics ctx [\#19239](https://github.com/netdata/netdata/pull/19239) ([ilyam8](https://github.com/ilyam8)) @@ -447,11 +451,6 @@ - fix system-info disk space in LXC [\#18696](https://github.com/netdata/netdata/pull/18696) ([ilyam8](https://github.com/ilyam8)) - fix ram usage calculation in LXC [\#18695](https://github.com/netdata/netdata/pull/18695) ([ilyam8](https://github.com/ilyam8)) - cgroups.plugin: call `setresuid` before spawn server init [\#18694](https://github.com/netdata/netdata/pull/18694) ([ilyam8](https://github.com/ilyam8)) -- Regenerate integrations.js [\#18693](https://github.com/netdata/netdata/pull/18693) ([netdatabot](https://github.com/netdatabot)) -- go.d/nvidia\_smi: use configured "timeout" in loop mode [\#18692](https://github.com/netdata/netdata/pull/18692) ([ilyam8](https://github.com/ilyam8)) -- fix\(cgroups.plugin\): handle containers no env vars [\#18691](https://github.com/netdata/netdata/pull/18691) ([daniel-sampliner](https://github.com/daniel-sampliner)) -- MSSQL Metrics \(Part II\). [\#18689](https://github.com/netdata/netdata/pull/18689) ([thiagoftsm](https://github.com/thiagoftsm)) -- Log to windows [\#18688](https://github.com/netdata/netdata/pull/18688) ([ktsaou](https://github.com/ktsaou)) ## [v1.47.5](https://github.com/netdata/netdata/tree/v1.47.5) (2024-10-24) diff --git a/packaging/version b/packaging/version index 04ef79e1b98bd3..0526daa7123738 100644 --- a/packaging/version +++ b/packaging/version @@ -1 +1 @@ -v2.0.0-260-nightly +v2.0.0-265-nightly