@cryptotaxi247 / netdata-1 / commits / b955368a9

Prefer context attributes from non archived charts (#13559)

prefer context attributes from non archived charts

Emmanuel Vasilakis committed Aug 23, 2022 at 18:14 UTC b955368a9088c1f33e0a14edc2468508f70d2c4f
1 file changed +14 -2
database/rrdcontext.c
+14 -2
@@ -1531,11 +1531,20 @@ static void rrdcontext_conflict_callback(const char *id, void *oldv, void *newv,
1531 RRDCONTEXT *rc = (RRDCONTEXT *)oldv;
1532 RRDCONTEXT *rc_new = (RRDCONTEXT *)newv;
1533
1534 + //current rc is not archived, new_rc is archived, dont merge
1535 + if (!rrd_flag_is_archived(rc) && rrd_flag_is_archived(rc_new)) {
1536 + rrdcontext_freez(rc_new);
1537 + return;
1538 + }
1539 +
1540 rrdcontext_lock(rc);
1541
1542 if(rc->title != rc_new->title) {
1543 STRING *old_title = rc->title;
1538 - rc->title = string_2way_merge(rc->title, rc_new->title);
1544 + if (rrd_flag_is_archived(rc) && !rrd_flag_is_archived(rc_new))
1545 + rc->title = string_dup(rc_new->title);
1546 + else
1547 + rc->title = string_2way_merge(rc->title, rc_new->title);
1548 string_freez(old_title);
1549 rrd_flag_set_updated(rc, RRD_FLAG_UPDATE_REASON_CHANGED_TITLE);
1550 }
@@ -1549,7 +1558,10 @@ static void rrdcontext_conflict_callback(const char *id, void *oldv, void *newv,
1558
1559 if(rc->family != rc_new->family) {
1560 STRING *old_family = rc->family;
1552 - rc->family = string_2way_merge(rc->family, rc_new->family);
1561 + if (rrd_flag_is_archived(rc) && !rrd_flag_is_archived(rc_new))
1562 + rc->family = string_dup(rc_new->family);
1563 + else
1564 + rc->family = string_2way_merge(rc->family, rc_new->family);
1565 string_freez(old_family);
1566 rrd_flag_set_updated(rc, RRD_FLAG_UPDATE_REASON_CHANGED_FAMILY);
1567 }