summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2023-12-29 19:42:45 +0200
committerGitHub <noreply@github.com>2023-12-29 19:42:45 +0200
commit8479f6d5e4ba72cfe4996ed1568d716b207945f7 (patch)
treec3b2e3ae1af0030dd615da699252e86c2e848d69 /database
parent77166afb0588f326bf6ab43bb94af926d119538b (diff)
fix quota calculation when the the db is empty (#16699)
* fix quota calculation when the the db is empty * do not compute workers utilization if extented statistics is not enabled
Diffstat (limited to 'database')
-rw-r--r--database/engine/rrdengine.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/database/engine/rrdengine.c b/database/engine/rrdengine.c
index f415fbcade..b82cc1ad18 100644
--- a/database/engine/rrdengine.c
+++ b/database/engine/rrdengine.c
@@ -1398,6 +1398,14 @@ uint64_t rrdeng_target_data_file_size(struct rrdengine_instance *ctx) {
bool rrdeng_ctx_exceeded_disk_quota(struct rrdengine_instance *ctx)
{
+ if(!ctx->datafiles.first)
+ // no datafiles available
+ return false;
+
+ if(!ctx->datafiles.first->next)
+ // only 1 datafile available
+ return false;
+
uint64_t estimated_disk_space = ctx_current_disk_space_get(ctx) + rrdeng_target_data_file_size(ctx) -
(ctx->datafiles.first->prev ? ctx->datafiles.first->prev->pos : 0);