@cryptotaxi247 / netdata-1 / commits / fe3dd763a

facets and journal improvements (#15956)

Costa Tsaousis committed Sep 13, 2023 at 13:30 UTC fe3dd763a905493d545eb771631760921f6bdb3a
2 files changed +15 -2
database/engine/rrdengineapi.c
+1 -1
@@ -815,7 +815,7 @@ static bool rrdeng_load_page_next(struct storage_engine_query_handle *rrddim_han
815 size_t entries = 0;
816 handle->page = pg_cache_lookup_next(ctx, handle->pdc, handle->now_s, handle->dt_s, &entries);
817
818 - internal_fatal((handle->page && pgc_page_data(handle->page) == DBENGINE_EMPTY_PAGE) || !entries,
818 + internal_fatal(handle->page && (pgc_page_data(handle->page) == DBENGINE_EMPTY_PAGE || !entries),
819 "A page was returned, but it is empty - pg_cache_lookup_next() should be handling this case");
820
821 if (unlikely(!handle->page || pgc_page_data(handle->page) == DBENGINE_EMPTY_PAGE || !entries))
libnetdata/facets/facets.c
+14 -1
@@ -1,6 +1,6 @@
1 #include "facets.h"
2
3 -#define HISTOGRAM_COLUMNS 60
3 +#define HISTOGRAM_COLUMNS 100
4
5 static void facets_row_free(FACETS *facets __maybe_unused, FACET_ROW *row);
6
@@ -1472,7 +1472,20 @@ void facets_report(FACETS *facets, BUFFER *wb) {
1472
1473 buffer_json_member_add_array(wb, "data");
1474 {
1475 + usec_t last_usec = 0;
1476 +
1477 for(FACET_ROW *row = facets->base ; row ;row = row->next) {
1478 +
1479 + internal_fatal(
1480 + facets->anchor.key && (
1481 + (facets->anchor.direction == FACETS_ANCHOR_DIRECTION_BACKWARD && row->usec >= facets->anchor.key) ||
1482 + (facets->anchor.direction == FACETS_ANCHOR_DIRECTION_FORWARD && row->usec <= facets->anchor.key)
1483 + ), "Wrong data returned related to %s anchor!", facets->anchor.direction == FACETS_ANCHOR_DIRECTION_FORWARD ? "forward" : "backward");
1484 +
1485 + internal_fatal(last_usec && row->usec > last_usec, "Wrong order of data returned!");
1486 +
1487 + last_usec = row->usec;
1488 +
1489 buffer_json_add_array_item_array(wb); // each row
1490 buffer_json_add_array_item_uint64(wb, row->usec);
1491