prevent gap filling on dbengine gaps (#13027)
Costa Tsaousis committed
May 27, 2022 at 18:43 UTC
abfa915126f896bd13ff1783db1a742eb880a15d
1 file changed
+10
-14
web/api/queries/query.c
+10
-14
@@ -540,25 +540,18 @@ static inline void do_dimension_fixedstep(
540
, time_t before_wanted
541
, uint32_t options
542
){
543
-#ifdef NETDATA_INTERNAL_CHECKS
544
- RRDSET *st = r->st;
545
-#endif
546
-
547
- time_t
548
- now = after_wanted,
543
+ time_t now = after_wanted,
544
dt = r->update_every / r->group, /* usually is st->update_every */
545
max_date = 0,
546
min_date = 0;
547
553
- long
554
- group_size = r->group,
548
+ long group_size = r->group,
549
points_added = 0,
550
values_in_group = 0,
551
values_in_group_non_zero = 0,
552
rrdr_line = -1;
553
560
- RRDR_VALUE_FLAGS
561
- group_value_flags = RRDR_VALUE_NOTHING;
554
+ RRDR_VALUE_FLAGS group_value_flags = RRDR_VALUE_NOTHING;
555
556
struct rrddim_query_handle handle;
557
@@ -595,8 +588,8 @@ static inline void do_dimension_fixedstep(
588
#ifdef NETDATA_INTERNAL_CHECKS
589
struct mem_query_handle* mem_handle = (struct mem_query_handle*)handle.handle;
590
if ((rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE) &&
598
- (rrdset_time2slot(st, now) != (long unsigned)(mem_handle->slot))) {
599
- error("INTERNAL CHECK: Unaligned query for %s, database slot: %lu, expected slot: %lu", rd->id, (long unsigned)mem_handle->slot, rrdset_time2slot(st, now));
591
+ (rrdset_time2slot(r->st, now) != (long unsigned)(mem_handle->slot))) {
592
+ error("INTERNAL CHECK: Unaligned query for %s, database slot: %lu, expected slot: %lu", rd->id, (long unsigned)mem_handle->slot, rrdset_time2slot(r->st, now));
593
}
594
#endif
595
@@ -612,6 +605,7 @@ static inline void do_dimension_fixedstep(
605
else {
606
// load the metric value
607
n = next_metric(&handle, &db_now);
608
+ db_points_read++;
609
610
// and unpack it
611
if(likely(does_storage_number_exist(n))) {
@@ -631,7 +625,10 @@ static inline void do_dimension_fixedstep(
625
break;
626
}
627
634
- for ( ; now <= db_now ; now += dt) {
628
+ // this loop exists only to fill nulls
629
+ // so, if there is a value already, we use it for the first iteration
630
+ // but the following iterations will just fill nulls to the destination
631
+ for ( ; now <= db_now ; now += dt, value = NAN, n = SN_EMPTY_SLOT) {
632
if(likely(does_storage_number_exist(n))) {
633
634
#if defined(NETDATA_INTERNAL_CHECKS) && defined(ENABLE_DBENGINE)
@@ -657,7 +654,6 @@ static inline void do_dimension_fixedstep(
654
655
// add this value for grouping
656
values_in_group++;
660
- db_points_read++;
657
658
if(unlikely(values_in_group == group_size)) {
659
rrdr_line = rrdr_line_init(r, now, rrdr_line);