Skip to content

Commit

Permalink
prevent reporting negative retention when the db is empty (#15796)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsaou authored and Ferroin committed Aug 16, 2023
1 parent 88d71a9 commit cf03ac9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion database/engine/rrdengineapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,12 @@ size_t rrdeng_disk_space_used(STORAGE_INSTANCE *db_instance) {

time_t rrdeng_global_first_time_s(STORAGE_INSTANCE *db_instance) {
struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
return __atomic_load_n(&ctx->atomic.first_time_s, __ATOMIC_RELAXED);

time_t t = __atomic_load_n(&ctx->atomic.first_time_s, __ATOMIC_RELAXED);
if(t == LONG_MAX || t < 0)
t = 0;

return t;
}

size_t rrdeng_currently_collected_metrics(STORAGE_INSTANCE *db_instance) {
Expand Down

0 comments on commit cf03ac9

Please sign in to comment.