summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2024-02-13 11:11:09 +0200
committerGitHub <noreply@github.com>2024-02-13 11:11:09 +0200
commit57eec3da0e51baa400037ccc4b547cb839ab6ffa (patch)
tree3d8d8c3366fa852073de35afb7cdf47f3bbc34fa
parent1e5967476d378fdabebb1cbb9741f70965dc8f0a (diff)
Adjust storage tiers if we fail to create the requested number of tiers (#16999)
Do not create a dbengine-tierX directory if the tier cannot be activated Check for datafiles existence during finalize of ctx Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
-rw-r--r--src/database/engine/datafile.c4
-rw-r--r--src/database/rrdhost.c35
2 files changed, 21 insertions, 18 deletions
diff --git a/src/database/engine/datafile.c b/src/database/engine/datafile.c
index 7322039cd3..1ec2dea799 100644
--- a/src/database/engine/datafile.c
+++ b/src/database/engine/datafile.c
@@ -557,7 +557,9 @@ void finalize_data_files(struct rrdengine_instance *ctx)
{
bool logged = false;
- logged = false;
+ if (!ctx->datafiles.first)
+ return;
+
while(__atomic_load_n(&ctx->atomic.extents_currently_being_flushed, __ATOMIC_RELAXED)) {
if(!logged) {
netdata_log_info("Waiting for inflight flush to finish on tier %d...", ctx->config.tier);
diff --git a/src/database/rrdhost.c b/src/database/rrdhost.c
index 2699ca8f34..b08df44ef5 100644
--- a/src/database/rrdhost.c
+++ b/src/database/rrdhost.c
@@ -879,23 +879,12 @@ void dbengine_init(char *hostname) {
struct dbengine_initialization tiers_init[RRD_STORAGE_TIERS] = {};
+ bool tiers_adjusted = false;
size_t created_tiers = 0;
char dbenginepath[FILENAME_MAX + 1];
char dbengineconfig[200 + 1];
int divisor = 1;
for(size_t tier = 0; tier < storage_tiers ;tier++) {
- if(tier == 0)
- snprintfz(dbenginepath, FILENAME_MAX, "%s/dbengine", netdata_configured_cache_dir);
- else
- snprintfz(dbenginepath, FILENAME_MAX, "%s/dbengine-tier%zu", netdata_configured_cache_dir, tier);
-
- int ret = mkdir(dbenginepath, 0775);
- if (ret != 0 && errno != EEXIST) {
- nd_log(NDLS_DAEMON, NDLP_CRIT,
- "DBENGINE on '%s': cannot create directory '%s'",
- hostname, dbenginepath);
- break;
- }
if(tier > 0)
divisor *= 2;
@@ -924,10 +913,7 @@ void dbengine_init(char *hostname) {
else if(strcmp(bf, "full") == 0) backfill = RRD_BACKFILL_FULL;
else if(strcmp(bf, "none") == 0) backfill = RRD_BACKFILL_NONE;
else {
- nd_log(NDLS_DAEMON, NDLP_WARNING,
- "DBENGINE: unknown backfill value '%s', assuming 'new'",
- bf);
-
+ nd_log(NDLS_DAEMON, NDLP_WARNING, "DBENGINE: unknown backfill value '%s', assuming 'new'", bf);
config_set(CONFIG_SECTION_DB, dbengineconfig, "new");
backfill = RRD_BACKFILL_NEW;
}
@@ -940,8 +926,21 @@ void dbengine_init(char *hostname) {
storage_tiers_grouping_iterations[tier] = 1;
nd_log(NDLS_DAEMON, NDLP_WARNING,
"DBENGINE on '%s': dbengine tier %zu gives aggregation of more than 65535 points of tier 0. "
- "Disabling tiers above %zu",
+ "Disabling tiers %zu and above",
hostname, tier, tier);
+ storage_tiers = tier;
+ tiers_adjusted = true;
+ break;
+ }
+
+ if(tier == 0)
+ snprintfz(dbenginepath, FILENAME_MAX, "%s/dbengine", netdata_configured_cache_dir);
+ else
+ snprintfz(dbenginepath, FILENAME_MAX, "%s/dbengine-tier%zu", netdata_configured_cache_dir, tier);
+
+ int ret = mkdir(dbenginepath, 0775);
+ if (ret != 0 && errno != EEXIST) {
+ nd_log(NDLS_DAEMON, NDLP_CRIT, "DBENGINE on '%s': cannot create directory '%s'", hostname, dbenginepath);
break;
}
@@ -961,6 +960,8 @@ void dbengine_init(char *hostname) {
else
dbengine_tier_init(&tiers_init[tier]);
}
+ if (tiers_adjusted)
+ config_set_number(CONFIG_SECTION_DB, "storage tiers", storage_tiers);
for(size_t tier = 0; tier < storage_tiers ;tier++) {
void *ptr;