@cryptotaxi247 / netdata-1 / commits / 3e6f8c019

do not discard old data on algorithm mismatch

Costa Tsaousis (ktsaou) committed Feb 11, 2017 at 22:11 UTC 3e6f8c0198fa7829db5688eedbdf0f134478e04b
1 file changed +6 -8
src/rrd.c
+6 -8
@@ -302,9 +302,9 @@ int rrd_memory_mode_id(const char *name)
302
303 int rrddim_algorithm_id(const char *name)
304 {
305 - if(strcmp(name, RRDDIM_INCREMENTAL_NAME) == 0) return RRDDIM_INCREMENTAL;
306 - if(strcmp(name, RRDDIM_ABSOLUTE_NAME) == 0) return RRDDIM_ABSOLUTE;
307 - if(strcmp(name, RRDDIM_PCENT_OVER_ROW_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_ROW_TOTAL;
305 + if(strcmp(name, RRDDIM_INCREMENTAL_NAME) == 0) return RRDDIM_INCREMENTAL;
306 + if(strcmp(name, RRDDIM_ABSOLUTE_NAME) == 0) return RRDDIM_ABSOLUTE;
307 + if(strcmp(name, RRDDIM_PCENT_OVER_ROW_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_ROW_TOTAL;
308 if(strcmp(name, RRDDIM_PCENT_OVER_DIFF_TOTAL_NAME) == 0) return RRDDIM_PCENT_OVER_DIFF_TOTAL;
309 return RRDDIM_ABSOLUTE;
310 }
@@ -692,11 +692,6 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
692 error("File %s does not have the same divisor. Clearing it.", fullfilename);
693 memset(rd, 0, size);
694 }
695 - else if(rd->algorithm != algorithm) {
696 - errno = 0;
697 - error("File %s does not have the same algorithm. Clearing it.", fullfilename);
698 - memset(rd, 0, size);
699 - }
695 else if(rd->update_every != st->update_every) {
696 errno = 0;
697 error("File %s does not have the same refresh frequency. Clearing it.", fullfilename);
@@ -714,6 +709,9 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, long multiplier
709 // rd = NULL;
710 memset(rd, 0, size);
711 }
712 +
713 + if(rd->algorithm && rd->algorithm != algorithm)
714 + error("File %s does not have the expected algorithm (expected %d '%s', found %d '%s'). Previous values may be wrong.", fullfilename, algorithm, rrddim_algorithm_name(algorithm), rd->algorithm, rrddim_algorithm_name(rd->algorithm));
715 }
716
717 if(rd) {