mirror of
https://github.com/netdata/netdata.git
synced 2025-04-25 21:43:55 +00:00
Fix crashes No 3 (#20007)
reinitialize data collection if an OBSOLETE or ARCHIVED dimension is collected
This commit is contained in:
parent
fd97fd9c05
commit
fe8d713e74
4 changed files with 22 additions and 11 deletions
src
|
@ -124,6 +124,7 @@ static inline void cgroup_free(struct cgroup *cg) {
|
|||
|
||||
rrdlabels_destroy(cg->chart_labels);
|
||||
|
||||
memset(cg, 0, sizeof(*cg));
|
||||
freez(cg);
|
||||
|
||||
cgroup_root_count--;
|
||||
|
|
|
@ -35,6 +35,16 @@ static void *rrddim_alloc_db(size_t entries) {
|
|||
return callocz(entries, sizeof(storage_number));
|
||||
}
|
||||
|
||||
static void rrddim_reinitialize_collection(RRDDIM *rd) {
|
||||
RRDSET *st = rd->rrdset;
|
||||
|
||||
for(size_t tier = 0; tier < nd_profile.storage_tiers; tier++) {
|
||||
if (!rd->tiers[tier].sch)
|
||||
rd->tiers[tier].sch =
|
||||
storage_metric_store_init(rd->tiers[tier].seb, rd->tiers[tier].smh, st->rrdhost->db[tier].tier_grouping * st->update_every, rd->rrdset->smg[tier]);
|
||||
}
|
||||
}
|
||||
|
||||
static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, void *rrddim, void *constructor_data) {
|
||||
struct rrddim_constructor *ctr = constructor_data;
|
||||
RRDDIM *rd = rrddim;
|
||||
|
@ -244,6 +254,8 @@ static void rrddim_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, v
|
|||
string_freez(rd->id);
|
||||
string_freez(rd->name);
|
||||
uuidmap_free(rd->uuid);
|
||||
|
||||
memset(rd, 0, sizeof(RRDDIM));
|
||||
}
|
||||
|
||||
static bool rrddim_conflict_callback(const DICTIONARY_ITEM *item __maybe_unused, void *rrddim, void *new_rrddim, void *constructor_data) {
|
||||
|
@ -255,19 +267,14 @@ static bool rrddim_conflict_callback(const DICTIONARY_ITEM *item __maybe_unused,
|
|||
|
||||
ctr->react_action = RRDDIM_REACT_NONE;
|
||||
|
||||
rrddim_flag_clear(rd, RRDDIM_FLAG_ARCHIVED | RRDDIM_FLAG_OBSOLETE);
|
||||
|
||||
int rc = rrddim_reset_name(st, rd, ctr->name);
|
||||
rc += rrddim_set_algorithm(st, rd, ctr->algorithm);
|
||||
rc += rrddim_set_multiplier(st, rd, ctr->multiplier);
|
||||
rc += rrddim_set_divisor(st, rd, ctr->divisor);
|
||||
|
||||
for(size_t tier = 0; tier < nd_profile.storage_tiers;tier++) {
|
||||
if (!rd->tiers[tier].sch)
|
||||
rd->tiers[tier].sch =
|
||||
storage_metric_store_init(rd->tiers[tier].seb, rd->tiers[tier].smh, st->rrdhost->db[tier].tier_grouping * st->update_every, rd->rrdset->smg[tier]);
|
||||
}
|
||||
|
||||
if(rrddim_flag_check(rd, RRDDIM_FLAG_ARCHIVED))
|
||||
rrddim_flag_clear(rd, RRDDIM_FLAG_ARCHIVED);
|
||||
rrddim_reinitialize_collection(rd);
|
||||
|
||||
if(unlikely(rc))
|
||||
ctr->react_action = RRDDIM_REACT_UPDATED;
|
||||
|
@ -559,7 +566,8 @@ inline void rrddim_is_obsolete___safe_from_collector_thread(RRDSET *st, RRDDIM *
|
|||
inline void rrddim_isnot_obsolete___safe_from_collector_thread(RRDSET *st __maybe_unused, RRDDIM *rd) {
|
||||
netdata_log_debug(D_RRD_CALLS, "rrddim_isnot_obsolete___safe_from_collector_thread() for chart %s, dimension %s", rrdset_name(st), rrddim_name(rd));
|
||||
|
||||
rrddim_flag_clear(rd, RRDDIM_FLAG_OBSOLETE);
|
||||
rrddim_flag_clear(rd, RRDDIM_FLAG_OBSOLETE|RRDDIM_FLAG_ARCHIVED);
|
||||
rrddim_reinitialize_collection(rd);
|
||||
rrdcontext_updated_rrddim_flags(rd);
|
||||
}
|
||||
|
||||
|
|
|
@ -686,8 +686,8 @@ void rrdset_timed_done(RRDSET *st, struct timeval now, bool pending_rrdset_next)
|
|||
last_collected_total += rd->collector.last_collected_value;
|
||||
collected_total += rd->collector.collected_value;
|
||||
|
||||
if(unlikely(rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE))) {
|
||||
netdata_log_error("Dimension %s in chart '%s' has the OBSOLETE flag set, but it is collected.", rrddim_name(rd), rrdset_id(st));
|
||||
if(unlikely(rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE | RRDDIM_FLAG_ARCHIVED))) {
|
||||
netdata_log_error("Dimension %s in chart '%s' has the OBSOLETE or ARCHIVED flag set, but it is collected.", rrddim_name(rd), rrdset_id(st));
|
||||
rrddim_isnot_obsolete___safe_from_collector_thread(st, rd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,6 +179,8 @@ static void rrdset_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, v
|
|||
string_freez(st->module_name);
|
||||
|
||||
freez(st->exporting_flags);
|
||||
|
||||
memset(st, 0, sizeof(RRDSET));
|
||||
}
|
||||
|
||||
// the item to be inserted, is already in the dictionary
|
||||
|
|
Loading…
Add table
Reference in a new issue