diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2023-02-22 22:06:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-22 22:06:22 +0200 |
commit | 7cd5570b49c5f156c944766dda7238611a969ff0 (patch) | |
tree | d7e149797bee824c8323f238bfc25960e068eac4 /database/engine/journalfile.c | |
parent | 37ba7d615d458a5246a93e8ad0e67294500d538c (diff) |
Get update every from page (#14573)
* Fix warning on conversion unsigned vs int
* For each metric get the update every from the last page stored in the journal
Diffstat (limited to 'database/engine/journalfile.c')
-rw-r--r-- | database/engine/journalfile.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c index 64d48d4fc0..fbf82696a7 100644 --- a/database/engine/journalfile.c +++ b/database/engine/journalfile.c @@ -894,6 +894,16 @@ static int journalfile_v2_validate(void *data_start, size_t journal_v2_file_size return 0; } +static inline time_t get_metric_latest_update_every(struct journal_page_header *metric_list_header) +{ + struct journal_page_list *metric_page = + (struct journal_page_list *)((uint8_t *)metric_list_header + sizeof(*metric_list_header)); + uint32_t entries = metric_list_header->entries; + if (unlikely(!entries)) + return 0; + return (time_t)metric_page[entries - 1].update_every_s; +} + void journalfile_v2_populate_retention_to_mrg(struct rrdengine_instance *ctx, struct rrdengine_journalfile *journalfile) { usec_t started_ut = now_monotonic_usec(); @@ -911,7 +921,7 @@ void journalfile_v2_populate_retention_to_mrg(struct rrdengine_instance *ctx, st for (size_t i=0; i < entries; i++) { time_t start_time_s = header_start_time_s + metric->delta_start_s; time_t end_time_s = header_start_time_s + metric->delta_end_s; - time_t update_every_s = (metric->entries > 1) ? ((end_time_s - start_time_s) / (entries - 1)) : 0; + time_t update_every_s = get_metric_latest_update_every((struct journal_page_header *) (data_start + metric->page_offset)); update_metric_retention_and_granularity_by_uuid( ctx, &metric->uuid, start_time_s, end_time_s, update_every_s, now_s); |