Check for chart obsoletion on children re-connections (#12707)

* check for chart obsoletion on children connections

* use rrdset_is_obsolete
This commit is contained in:
Emmanuel Vasilakis 2022-05-03 10:37:14 +03:00 committed by GitHub
parent 22863c42b9
commit 0996abc7c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View File

@ -827,6 +827,8 @@ struct rrdhost {
struct receiver_state *receiver;
netdata_mutex_t receiver_lock;
time_t trigger_chart_obsoletion_check; // set when child connects, will instruct parent to
// trigger a check for obsoleted charts since previous connect
// ------------------------------------------------------------------------
// health monitoring options

View File

@ -1528,6 +1528,16 @@ restart_after_removal:
}
}
void rrdset_check_obsoletion(RRDHOST *host)
{
RRDSET *st;
rrdset_foreach_write(st, host) {
if (rrdset_last_entry_t(st) < host->trigger_chart_obsoletion_check) {
rrdset_is_obsolete(st);
}
}
}
void rrd_cleanup_obsolete_charts()
{
rrd_rdlock();
@ -1547,6 +1557,15 @@ void rrd_cleanup_obsolete_charts()
#endif
rrdhost_unlock(host);
}
if (host != localhost &&
host->trigger_chart_obsoletion_check &&
host->trigger_chart_obsoletion_check + 120 < now_realtime_sec()) {
rrdhost_wrlock(host);
rrdset_check_obsoletion(host);
rrdhost_unlock(host);
host->trigger_chart_obsoletion_check = 0;
}
}
rrd_unlock();

View File

@ -808,7 +808,6 @@ void *health_main(void *ptr) {
#endif
}
}
continue;
}
if (unlikely(!rrdcalc_isrunnable(rc, now, &next_run))) {

View File

@ -646,6 +646,7 @@ static int rrdpush_receive(struct receiver_state *rpt)
rpt->host->hostname);
}
}
rpt->host->trigger_chart_obsoletion_check = now_realtime_sec();
rrdhost_unlock(rpt->host);
// call the plugins.d processor to receive the metrics
@ -686,6 +687,7 @@ static int rrdpush_receive(struct receiver_state *rpt)
if(health_enabled == CONFIG_BOOLEAN_AUTO)
rpt->host->health_enabled = 0;
}
rpt->host->trigger_chart_obsoletion_check = 0;
rrdhost_unlock(rpt->host);
if (rpt->host->receiver == rpt) {
rrdpush_sender_thread_stop(rpt->host);