prevent reporting negative retention when the db is empty (#15796)
Costa Tsaousis committed
Aug 11, 2023 at 23:37 UTC
a66e22730dc4600f73c5841a6fb9a3f4b2714b5f
1 file changed
+6
-1
database/engine/rrdengineapi.c
+6
-1
@@ -1014,7 +1014,12 @@ size_t rrdeng_disk_space_used(STORAGE_INSTANCE *db_instance) {
1014
1015
time_t rrdeng_global_first_time_s(STORAGE_INSTANCE *db_instance) {
1016
struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
1017
- return __atomic_load_n(&ctx->atomic.first_time_s, __ATOMIC_RELAXED);
1017
+
1018
+ time_t t = __atomic_load_n(&ctx->atomic.first_time_s, __ATOMIC_RELAXED);
1019
+ if(t == LONG_MAX || t < 0)
1020
+ t = 0;
1021
+
1022
+ return t;
1023
}
1024
1025
size_t rrdeng_currently_collected_metrics(STORAGE_INSTANCE *db_instance) {