summaryrefslogtreecommitdiffstats
path: root/database/engine/journalfile.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-08-12 07:26:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-08-12 07:26:11 +0000
commit3c315f0fff93aa072472abc10815963ac0035268 (patch)
treea95f6a96e0e7bd139c010f8dc60b40e5b3062a99 /database/engine/journalfile.c
parentAdding upstream version 1.35.1. (diff)
downloadnetdata-3c315f0fff93aa072472abc10815963ac0035268.tar.xz
netdata-3c315f0fff93aa072472abc10815963ac0035268.zip
Adding upstream version 1.36.0.upstream/1.36.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'database/engine/journalfile.c')
-rw-r--r--database/engine/journalfile.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c
index 0b3d3eeb..dc61f569 100644
--- a/database/engine/journalfile.c
+++ b/database/engine/journalfile.c
@@ -275,6 +275,7 @@ static int check_journal_file_superblock(uv_file file)
static void restore_extent_metadata(struct rrdengine_instance *ctx, struct rrdengine_journalfile *journalfile,
void *buf, unsigned max_size)
{
+ static BITMAP256 page_error_map;
struct page_cache *pg_cache = &ctx->pg_cache;
unsigned i, count, payload_length, descr_size, valid_pages;
struct rrdeng_page_descr *descr;
@@ -301,11 +302,31 @@ static void restore_extent_metadata(struct rrdengine_instance *ctx, struct rrden
uuid_t *temp_id;
Pvoid_t *PValue;
struct pg_cache_page_index *page_index = NULL;
+ uint8_t page_type = jf_metric_data->descr[i].type;
- if (PAGE_METRICS != jf_metric_data->descr[i].type) {
- error("Unknown page type encountered.");
+ if (page_type > PAGE_TYPE_MAX) {
+ if (!bitmap256_get_bit(&page_error_map, page_type)) {
+ error("Unknown page type %d encountered.", page_type);
+ bitmap256_set_bit(&page_error_map, page_type, 1);
+ }
continue;
}
+ uint64_t start_time = jf_metric_data->descr[i].start_time;
+ uint64_t end_time = jf_metric_data->descr[i].end_time;
+
+ if (unlikely(start_time > end_time)) {
+ error("Invalid page encountered, start time %lu > end time %lu", start_time , end_time );
+ continue;
+ }
+
+ if (unlikely(start_time == end_time)) {
+ size_t entries = jf_metric_data->descr[i].page_length / page_type_size[page_type];
+ if (unlikely(entries > 1)) {
+ error("Invalid page encountered, start time %lu = end time but %zu entries were found", start_time, entries);
+ continue;
+ }
+ }
+
temp_id = (uuid_t *)jf_metric_data->descr[i].uuid;
uv_rwlock_rdlock(&pg_cache->metrics_index.lock);
@@ -327,10 +348,11 @@ static void restore_extent_metadata(struct rrdengine_instance *ctx, struct rrden
descr = pg_cache_create_descr();
descr->page_length = jf_metric_data->descr[i].page_length;
- descr->start_time = jf_metric_data->descr[i].start_time;
- descr->end_time = jf_metric_data->descr[i].end_time;
+ descr->start_time = start_time;
+ descr->end_time = end_time;
descr->id = &page_index->id;
descr->extent = extent;
+ descr->type = page_type;
extent->pages[valid_pages++] = descr;
pg_cache_insert(ctx, page_index, descr);
}