@cryptotaxi247 / netdata-1 / commits / 606557532

do not process contexts before they are loaded (#19401)

Costa Tsaousis committed Jan 15, 2025 at 09:58 UTC 606557532743cd07f8e8a8223e86d406af690cec
2 files changed +9 -3
src/database/contexts/worker.c
+3
@@ -1017,6 +1017,9 @@ void *rrdcontext_main(void *ptr) {
1017 dfe_start_reentrant(rrdhost_root_index, host) {
1018 if(unlikely(!service_running(SERVICE_CONTEXT))) break;
1019
1020 + if(rrdhost_flag_check(host, RRDHOST_FLAG_PENDING_CONTEXT_LOAD))
1021 + continue;
1022 +
1023 worker_is_busy(WORKER_JOB_HOSTS);
1024
1025 if(host->rrdctx.pp_queue) {
src/database/engine/metric.c
+6 -3
@@ -417,6 +417,9 @@ inline Word_t mrg_metric_section(MRG *mrg __maybe_unused, METRIC *metric) {
417 inline bool mrg_metric_set_first_time_s(MRG *mrg __maybe_unused, METRIC *metric, time_t first_time_s) {
418 internal_fatal(first_time_s < 0, "DBENGINE METRIC: timestamp is negative");
419
420 + if(first_time_s == LONG_MAX)
421 + first_time_s = 0;
422 +
423 if(unlikely(first_time_s < 0))
424 return false;
425
@@ -433,8 +436,8 @@ inline void mrg_metric_expand_retention(MRG *mrg __maybe_unused, METRIC *metric,
436 internal_fatal(last_time_s > max_acceptable_collected_time(),
437 "DBENGINE METRIC: metric last time is in the future");
438
436 - if(first_time_s > 0)
437 - set_metric_field_with_condition(metric->first_time_s, first_time_s, _current <= 0 || _wanted < _current);
439 + if(first_time_s > 0 && first_time_s != LONG_MAX)
440 + set_metric_field_with_condition(metric->first_time_s, first_time_s, _current <= 0 || (_wanted != 0 && _wanted != LONG_MAX && _wanted < _current));
441
442 if(last_time_s > 0) {
443 if(set_metric_field_with_condition(metric->latest_time_s_clean, last_time_s, _current <= 0 || _wanted > _current) &&
@@ -449,7 +452,7 @@ inline void mrg_metric_expand_retention(MRG *mrg __maybe_unused, METRIC *metric,
452
453 inline bool mrg_metric_set_first_time_s_if_bigger(MRG *mrg __maybe_unused, METRIC *metric, time_t first_time_s) {
454 internal_fatal(first_time_s < 0, "DBENGINE METRIC: timestamp is negative");
452 - return set_metric_field_with_condition(metric->first_time_s, first_time_s, _wanted > _current);
455 + return set_metric_field_with_condition(metric->first_time_s, first_time_s, _wanted != 0 && _wanted != LONG_MAX && _wanted > _current);
456 }
457
458 inline time_t mrg_metric_get_first_time_s(MRG *mrg __maybe_unused, METRIC *metric) {