Fix so that allow_past correctly works in memory mode ram and save (#12136)
Stelios Fragkakis committed
Feb 17, 2022 at 09:12 UTC
15dd0e4b5ae301e9a9a31870e74f654cec033135
1 file changed
+6
-2
web/api/queries/query.c
+6
-2
@@ -562,7 +562,7 @@ static inline void do_dimension_fixedstep(
562
calculated_number min = r->min, max = r->max;
563
size_t db_points_read = 0;
564
time_t db_now = now;
565
-
565
+ time_t first_time_t = rrddim_first_entry_t(rd);
566
for(rd->state->query_ops.init(rd, &handle, now, before_wanted) ; points_added < points_wanted ; now += dt) {
567
// make sure we return data in the proper time range
568
if(unlikely(now > before_wanted)) {
@@ -586,7 +586,11 @@ static inline void do_dimension_fixedstep(
586
}
587
#endif
588
db_now = now; // this is needed to set db_now in case the next_metric implementation does not set it
589
- storage_number n = rd->state->query_ops.next_metric(&handle, &db_now);
589
+ storage_number n;
590
+ if (rd->rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE && now <= first_time_t)
591
+ n = SN_EMPTY_SLOT;
592
+ else
593
+ n = rd->state->query_ops.next_metric(&handle, &db_now);
594
if(unlikely(db_now > before_wanted)) {
595
#ifdef NETDATA_INTERNAL_CHECKS
596
r->internal.log = "stopped, because attempted to access the db after 'wanted before'";