diff options
Diffstat (limited to '')
-rw-r--r-- | database/rrdlabels.c | 34 | ||||
-rw-r--r-- | database/rrdset.c | 1 | ||||
-rw-r--r-- | database/sqlite/sqlite_aclk_alert.c | 4 | ||||
-rw-r--r-- | database/sqlite/sqlite_functions.c | 2 |
4 files changed, 20 insertions, 21 deletions
diff --git a/database/rrdlabels.c b/database/rrdlabels.c index 75167cb24..6505b4b2d 100644 --- a/database/rrdlabels.c +++ b/database/rrdlabels.c @@ -683,7 +683,7 @@ static RRDLABEL *rrdlabels_find_label_with_key_unsafe(RRDLABELS *labels, RRDLABE RRDLABEL *found = NULL; while ((PValue = JudyLFirstThenNext(labels->JudyL, &Index, &first_then_next))) { RRDLABEL *lb = (RRDLABEL *)Index; - if (lb->index.key == label->index.key) { + if (lb->index.key == label->index.key && lb != label) { found = (RRDLABEL *)Index; break; } @@ -700,13 +700,7 @@ static void labels_add_already_sanitized(RRDLABELS *labels, const char *key, con spinlock_lock(&labels->spinlock); - RRDLABEL *old_label_with_key = rrdlabels_find_label_with_key_unsafe(labels, new_label); - - if (old_label_with_key == new_label) { - spinlock_unlock(&labels->spinlock); - delete_label(new_label); - return; - } + RRDLABEL_SRC new_ls = (ls & ~(RRDLABEL_FLAG_NEW | RRDLABEL_FLAG_OLD)); size_t mem_before_judyl = JudyLMemUsed(labels->JudyL); @@ -714,24 +708,27 @@ static void labels_add_already_sanitized(RRDLABELS *labels, const char *key, con if (!PValue || PValue == PJERR) fatal("RRDLABELS: corrupted labels JudyL array"); - RRDLABEL_SRC new_ls = (ls & ~(RRDLABEL_FLAG_NEW | RRDLABEL_FLAG_OLD)); - labels->version++; - - if (old_label_with_key) { - (void)JudyLDel(&labels->JudyL, (Word_t)old_label_with_key, PJE0); + if(*PValue) { new_ls |= RRDLABEL_FLAG_OLD; - } else + delete_label(new_label); + } + else { new_ls |= RRDLABEL_FLAG_NEW; + RRDLABEL *old_label_with_same_key = rrdlabels_find_label_with_key_unsafe(labels, new_label); + if (old_label_with_same_key) { + (void) JudyLDel(&labels->JudyL, (Word_t) old_label_with_same_key, PJE0); + delete_label(old_label_with_same_key); + } + } + + labels->version++; *((RRDLABEL_SRC *)PValue) = new_ls; size_t mem_after_judyl = JudyLMemUsed(labels->JudyL); STATS_PLUS_MEMORY(&dictionary_stats_category_rrdlabels, 0, mem_after_judyl - mem_before_judyl, 0); spinlock_unlock(&labels->spinlock); - - if (old_label_with_key) - delete_label((RRDLABEL *)old_label_with_key); } void rrdlabels_add(RRDLABELS *labels, const char *name, const char *value, RRDLABEL_SRC ls) @@ -1043,8 +1040,6 @@ void rrdlabels_copy(RRDLABELS *dst, RRDLABELS *src) lfe_start_nolock(src, label, ls) { RRDLABEL *old_label_with_key = rrdlabels_find_label_with_key_unsafe(dst, label); - if (old_label_with_key && old_label_with_key == label) - continue; Pvoid_t *PValue = JudyLIns(&dst->JudyL, (Word_t)label, PJE0); if(unlikely(!PValue || PValue == PJERR)) @@ -1307,6 +1302,7 @@ void rrdset_update_rrdlabels(RRDSET *st, RRDLABELS *new_rrdlabels) { rrdset_flag_set(st, RRDSET_FLAG_METADATA_UPDATE); rrdhost_flag_set(st->rrdhost, RRDHOST_FLAG_METADATA_UPDATE); + rrdset_flag_clear(st, RRDSET_FLAG_UPSTREAM_EXPOSED); } diff --git a/database/rrdset.c b/database/rrdset.c index cf8b9ef85..92386f45e 100644 --- a/database/rrdset.c +++ b/database/rrdset.c @@ -389,6 +389,7 @@ static void rrdset_react_callback(const DICTIONARY_ITEM *item __maybe_unused, vo } rrdset_flag_set(st, RRDSET_FLAG_METADATA_UPDATE); rrdhost_flag_set(st->rrdhost, RRDHOST_FLAG_METADATA_UPDATE); + rrdset_flag_clear(st, RRDSET_FLAG_UPSTREAM_EXPOSED); } rrdcontext_updated_rrdset(st); diff --git a/database/sqlite/sqlite_aclk_alert.c b/database/sqlite/sqlite_aclk_alert.c index e25b0f0ec..60bf5dbdc 100644 --- a/database/sqlite/sqlite_aclk_alert.c +++ b/database/sqlite/sqlite_aclk_alert.c @@ -71,9 +71,9 @@ fail: //decide if some events should be sent or not #define SQL_SELECT_ALERT_BY_ID \ "SELECT hld.new_status, hl.config_hash_id, hld.unique_id FROM health_log hl, aclk_alert_%s aa, health_log_detail hld " \ - "WHERE hl.host_id = @host_id AND hld.unique_id = aa.filtered_alert_unique_id " \ + "WHERE hl.host_id = @host_id AND +hld.unique_id = aa.filtered_alert_unique_id " \ "AND hld.alarm_id = @alarm_id AND hl.health_log_id = hld.health_log_id " \ - "ORDER BY hld.alarm_event_id DESC LIMIT 1;" + "ORDER BY hld.rowid DESC LIMIT 1;" static bool should_send_to_cloud(RRDHOST *host, ALARM_ENTRY *ae) { diff --git a/database/sqlite/sqlite_functions.c b/database/sqlite/sqlite_functions.c index e081fe9ae..393d6a238 100644 --- a/database/sqlite/sqlite_functions.c +++ b/database/sqlite/sqlite_functions.c @@ -60,6 +60,8 @@ const char *database_config[] = { "CREATE INDEX IF NOT EXISTS health_log_d_ind_3 ON health_log_detail (transition_id);", "CREATE INDEX IF NOT EXISTS health_log_d_ind_5 ON health_log_detail (health_log_id, unique_id DESC);", "CREATE INDEX IF NOT EXISTS health_log_d_ind_6 on health_log_detail (health_log_id, when_key)", + "CREATE INDEX IF NOT EXISTS health_log_d_ind_7 on health_log_detail (alarm_id);", + "CREATE INDEX IF NOT EXISTS health_log_d_ind_8 on health_log_detail (new_status, updated_by_id);", NULL }; |