summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorvkalintiris <vasilis@netdata.cloud>2023-07-26 15:30:49 +0300
committerGitHub <noreply@github.com>2023-07-26 15:30:49 +0300
commit440bd51e08fdfa2a4daa191fb68643456028a753 (patch)
tree1d2cc2b0afc24b6b77f95f2cf3a1bdbaa544e278 /database
parent3829b4c48ade535aa2d0a1153d45b49184b27a4b (diff)
Refactor RRD code. (#15423)
* Storage engine. * Host indexes to rrdb * Move globals to rrdb * Move storage_tiers_backfill to rrdb * default_rrd_update_every to rrdb * default_rrd_history_entries to rrdb * gap_when_lost_iterations_above to rrdb * rrdset_free_obsolete_time_s to rrdb * libuv_worker_threads to rrdb * ieee754_doubles to rrdb * rrdhost_free_orphan_time_s to rrdb * rrd_rwlock to rrdb * localhost to rrdb * rm extern from func decls * mv rrd macro under rrd.h * default_rrdeng_page_cache_mb to rrdb * default_rrdeng_extent_cache_mb to rrdb * db_engine_journal_check to rrdb * default_rrdeng_disk_quota_mb to rrdb * default_multidb_disk_quota_mb to rrdb * multidb_ctx to rrdb * page_type_size to rrdb * tier_page_size to rrdb * No storage_engine_id in rrdim functions * storage_engine_id is provided by st * Update to fix merge conflict. * Update field name * Remove unnecessary macros from rrd.h * Rm unused type decls * Rm duplicate func decls * make internal function static * Make the rest of public dbengine funcs accept a storage_instance. * No more rrdengine_instance :) * rm rrdset_debug from rrd.h * Use rrdb to access globals in ML and ACLK Missed due to not having the submodules in the worktree. * rm total_number * rm RRDVAR_TYPE_TOTAL * rm unused inline * Rm names from typedef'd enums * rm unused header include * Move include * Rm unused header include * s/rrdhost_find_or_create/rrdhost_get_or_create/g * s/find_host_by_node_id/rrdhost_find_by_node_id/ Also, remove duplicate definition in rrdcontext.c * rm macro used only once * rm macro used only once * Reduce rrd.h api by moving funcs into a collector specific utils header * Remove unused func * Move parser specific function out of rrd.h * return storage_number instead of void pointer * move code related to rrd initialization out of rrdhost.c * Remove tier_grouping from rrdim_tier Saves 8 * storage_tiers bytes per dimension. * Fix rebase * s/rrd_update_every/update_every/ * Mark functions as static and constify args * Add license notes and file to build systems. * Remove remaining non-log/config mentions of memory mode * Move rrdlabels api to separate file. Also, move localhost functions that loads labels outside of database/ and into daemon/ * Remove function decl in rrd.h * merge rrdhost_cache_dir_for_rrdset_alloc into rrdset_cache_dir * Do not expose internal function from rrd.h * Rm NETDATA_RRD_INTERNALS Only one function decl is covered. We have more database internal functions that we currently expose for no good reason. These will be placed in a separate internal header in follow up PRs. * Add license note * Include libnetdata.h instead of aral.h * Use rrdb to access localhost * Fix builds without dbengine * Add header to build system files * Add rrdlabels.h to build systems * Move func def from rrd.h to rrdhost.c * Fix macos build * Rm non-existing function * Rebase master * Define buffer length macro in ad_charts. * Fix FreeBSD builds. * Mark functions static * Rm func decls without definitions * Rebase master * Rebase master * Properly initialize value of storage tiers. * Fix build after rebase.
Diffstat (limited to 'database')
-rw-r--r--database/contexts/api_v2.c29
-rw-r--r--database/contexts/internal.h1
-rw-r--r--database/contexts/query_scope.c2
-rw-r--r--database/contexts/query_target.c38
-rw-r--r--database/contexts/rrdcontext.c25
-rw-r--r--database/contexts/rrdcontext.h2
-rw-r--r--database/contexts/worker.c12
-rw-r--r--database/engine/cache.c2
-rw-r--r--database/engine/cache.h2
-rw-r--r--database/engine/datafile.c4
-rw-r--r--database/engine/journalfile.c12
-rw-r--r--database/engine/metric.c2
-rw-r--r--database/engine/metric.h2
-rw-r--r--database/engine/pagecache.c9
-rw-r--r--database/engine/pdc.c4
-rw-r--r--database/engine/rrddim_eng.h73
-rw-r--r--database/engine/rrdengine.c25
-rw-r--r--database/engine/rrdengine.h2
-rw-r--r--[-rwxr-xr-x]database/engine/rrdengineapi.c155
-rw-r--r--database/engine/rrdengineapi.h63
-rw-r--r--database/engine/rrdenginelib.c4
-rw-r--r--database/ram/rrddim_mem.c25
-rw-r--r--database/ram/rrddim_mem.h37
-rw-r--r--database/rrd.c441
-rw-r--r--database/rrd.h681
-rw-r--r--database/rrdcalc.c2
-rw-r--r--database/rrddim.c443
-rw-r--r--database/rrdfamily.c1
-rw-r--r--database/rrdfunctions.c7
-rw-r--r--database/rrdfunctions.h2
-rw-r--r--database/rrdhost.c702
-rw-r--r--database/rrdlabels.c32
-rw-r--r--database/rrdlabels.h60
-rw-r--r--database/rrdset.c659
-rw-r--r--database/rrdvar.c5
-rw-r--r--database/rrdvar.h3
-rw-r--r--database/sqlite/sqlite_aclk.c16
-rw-r--r--database/sqlite/sqlite_aclk.h2
-rw-r--r--database/sqlite/sqlite_aclk_alert.c16
-rw-r--r--database/sqlite/sqlite_aclk_node.c12
-rw-r--r--database/sqlite/sqlite_functions.c16
-rw-r--r--database/sqlite/sqlite_functions.h2
-rw-r--r--database/sqlite/sqlite_health.c14
-rw-r--r--database/sqlite/sqlite_metadata.c34
-rw-r--r--database/storage_engine.c143
-rw-r--r--database/storage_engine.h451
-rw-r--r--database/storage_engine_types.h56
47 files changed, 2132 insertions, 2198 deletions
diff --git a/database/contexts/api_v2.c b/database/contexts/api_v2.c
index ed7f955ada..3bd6e3051d 100644
--- a/database/contexts/api_v2.c
+++ b/database/contexts/api_v2.c
@@ -802,7 +802,7 @@ static void rrdcontext_to_json_v2_rrdhost(BUFFER *wb, RRDHOST *host, struct rrdc
{
buffer_json_member_add_string(wb, "status", rrdhost_db_status_to_string(s.db.status));
buffer_json_member_add_string(wb, "liveness", rrdhost_db_liveness_to_string(s.db.liveness));
- buffer_json_member_add_string(wb, "mode", rrd_memory_mode_name(s.db.mode));
+ buffer_json_member_add_string(wb, "mode", storage_engine_name(s.db.storage_engine_id));
buffer_json_member_add_time_t(wb, "first_time", s.db.first_time_s);
buffer_json_member_add_time_t(wb, "last_time", s.db.last_time_s);
buffer_json_member_add_uint64(wb, "metrics", s.db.metrics);
@@ -989,9 +989,9 @@ void buffer_json_agents_v2(BUFFER *wb, struct query_timings *timings, time_t now
else
buffer_json_member_add_object(wb, "agent");
- buffer_json_member_add_string(wb, "mg", localhost->machine_guid);
- buffer_json_member_add_uuid(wb, "nd", localhost->node_id);
- buffer_json_member_add_string(wb, "nm", rrdhost_hostname(localhost));
+ buffer_json_member_add_string(wb, "mg", rrdb.localhost->machine_guid);
+ buffer_json_member_add_uuid(wb, "nd", rrdb.localhost->node_id);
+ buffer_json_member_add_string(wb, "nm", rrdhost_hostname(rrdb.localhost));
buffer_json_member_add_time_t(wb, "now", now_s);
if(array)
@@ -1005,14 +1005,13 @@ void buffer_json_agents_v2(BUFFER *wb, struct query_timings *timings, time_t now
buffer_json_cloud_status(wb, now_s);
buffer_json_member_add_array(wb, "db_size");
- for (size_t tier = 0; tier < storage_tiers; tier++) {
- STORAGE_ENGINE *eng = localhost->db[tier].eng;
- if (!eng) continue;
+ for (size_t tier = 0; tier < rrdb.storage_tiers; tier++) {
+ STORAGE_ENGINE_ID storage_engine_id = rrdb.localhost->db[tier].id;
- size_t max = storage_engine_disk_space_max(eng->backend, localhost->db[tier].instance);
- size_t used = storage_engine_disk_space_used(eng->backend, localhost->db[tier].instance);
- time_t first_time_s = storage_engine_global_first_time_s(eng->backend, localhost->db[tier].instance);
- size_t currently_collected_metrics = storage_engine_collected_metrics(eng->backend, localhost->db[tier].instance);
+ size_t max = storage_engine_disk_space_max(storage_engine_id, rrdb.localhost->db[tier].instance);
+ size_t used = storage_engine_disk_space_used(storage_engine_id, rrdb.localhost->db[tier].instance);
+ time_t first_time_s = storage_engine_global_first_time_s(storage_engine_id, rrdb.localhost->db[tier].instance);
+ size_t currently_collected_metrics = storage_engine_collected_metrics(storage_engine_id, rrdb.localhost->db[tier].instance);
NETDATA_DOUBLE percent;
if (used && max)
@@ -1258,7 +1257,7 @@ static void contexts_v2_alert_config_to_json_from_sql_alert_config_data(struct s
{
buffer_json_member_add_string(wb, "type", "agent");
buffer_json_member_add_string(wb, "exec", t->notification.exec ? t->notification.exec : NULL);
- buffer_json_member_add_string(wb, "to", t->notification.to_key ? t->notification.to_key : string2str(localhost->health.health_default_recipient));
+ buffer_json_member_add_string(wb, "to", t->notification.to_key ? t->notification.to_key : string2str(rrdb.localhost->health.health_default_recipient));
buffer_json_member_add_string(wb, "delay", t->notification.delay);
buffer_json_member_add_string(wb, "repeat", t->notification.repeat);
buffer_json_member_add_string(wb, "options", t->notification.options);
@@ -1575,7 +1574,7 @@ static void contexts_v2_alert_transition_callback(struct sql_alert_transition_da
[ATF_CLASS] = t->classification,
[ATF_TYPE] = t->type,
[ATF_COMPONENT] = t->component,
- [ATF_ROLE] = t->recipient && *t->recipient ? t->recipient : string2str(localhost->health.health_default_recipient),
+ [ATF_ROLE] = t->recipient && *t->recipient ? t->recipient : string2str(rrdb.localhost->health.health_default_recipient),
[ATF_NODE] = machine_guid,
[ATF_ALERT_NAME] = t->alert_name,
[ATF_CHART_NAME] = t->chart_name,
@@ -1745,9 +1744,9 @@ static void contexts_v2_alert_transitions_to_json(BUFFER *wb, struct rrdcontext_
buffer_json_member_add_time_t(wb, "delay", t->delay);
buffer_json_member_add_time_t(wb, "delay_up_to_time", t->delay_up_to_timestamp);
health_entry_flags_to_json_array(wb, "flags", t->flags);
- buffer_json_member_add_string(wb, "exec", *t->exec ? t->exec : string2str(localhost->health.health_default_exec));
+ buffer_json_member_add_string(wb, "exec", *t->exec ? t->exec : string2str(rrdb.localhost->health.health_default_exec));
buffer_json_member_add_uint64(wb, "exec_code", t->exec_code);
- buffer_json_member_add_string(wb, "to", *t->recipient ? t->recipient : string2str(localhost->health.health_default_recipient));
+ buffer_json_member_add_string(wb, "to", *t->recipient ? t->recipient : string2str(rrdb.localhost->health.health_default_recipient));
}
buffer_json_object_close(wb); // notification
}
diff --git a/database/contexts/internal.h b/database/contexts/internal.h
index c5663dd248..bdd1fa4bc4 100644
--- a/database/contexts/internal.h
+++ b/database/contexts/internal.h
@@ -8,7 +8,6 @@
#include "../../aclk/schema-wrappers/context.h"
#include "../../aclk/aclk_contexts_api.h"
#include "../../aclk/aclk.h"
-#include "../storage_engine.h"
#define MESSAGES_PER_BUNDLE_TO_SEND_TO_HUB_PER_HOST 5000
#define FULL_RETENTION_SCAN_DELAY_AFTER_DB_ROTATION_SECS 120
diff --git a/database/contexts/query_scope.c b/database/contexts/query_scope.c
index f3bcd0b3fa..a7f8488ca3 100644
--- a/database/contexts/query_scope.c
+++ b/database/contexts/query_scope.c
@@ -17,7 +17,7 @@ ssize_t query_scope_foreach_host(SIMPLE_PATTERN *scope_hosts_sp, SIMPLE_PATTERN
uint64_t a_hash = 0;
uint64_t t_hash = 0;
- dfe_start_read(rrdhost_root_index, host) {
+ dfe_start_read(rrdb.rrdhost_root_index, host) {
if(host->node_id)
uuid_unparse_lower(*host->node_id, host_node_id_str);
else
diff --git a/database/contexts/query_target.c b/database/contexts/query_target.c
index 508977ce7a..e2e36a11ea 100644
--- a/database/contexts/query_target.c
+++ b/database/contexts/query_target.c
@@ -211,19 +211,19 @@ typedef struct query_target_locals {
QUERY_NODE *qn; // temp to pass on callbacks, ignore otherwise - no need to free
} QUERY_TARGET_LOCALS;
-struct storage_engine *query_metric_storage_engine(QUERY_TARGET *qt, QUERY_METRIC *qm, size_t tier) {
+STORAGE_ENGINE_ID query_metric_storage_engine(QUERY_TARGET *qt, QUERY_METRIC *qm, size_t tier) {
QUERY_NODE *qn = query_node(qt, qm->link.query_node_id);
- return qn->rrdhost->db[tier].eng;
+ return qn->rrdhost->db[tier].id;
}
static inline void query_metric_release(QUERY_TARGET *qt, QUERY_METRIC *qm) {
qm->plan.used = 0;
// reset the tiers
- for(size_t tier = 0; tier < storage_tiers ;tier++) {
+ for(size_t tier = 0; tier < rrdb.storage_tiers ;tier++) {
if(qm->tiers[tier].db_metric_handle) {
- STORAGE_ENGINE *eng = query_metric_storage_engine(qt, qm, tier);
- eng->api.metric_release(qm->tiers[tier].db_metric_handle);
+ STORAGE_ENGINE_ID storage_engine_id = query_metric_storage_engine(qt, qm, tier);
+ storage_engine_metric_release(storage_engine_id, qm->tiers[tier].db_metric_handle);
qm->tiers[tier].db_metric_handle = NULL;
}
}
@@ -240,26 +240,26 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
size_t tiers_added = 0;
struct {
- STORAGE_ENGINE *eng;
+ STORAGE_ENGINE_ID storage_engine_id;
STORAGE_METRIC_HANDLE *db_metric_handle;
time_t db_first_time_s;
time_t db_last_time_s;
time_t db_update_every_s;
- } tier_retention[storage_tiers];
+ } tier_retention[rrdb.storage_tiers];
- for (size_t tier = 0; tier < storage_tiers; tier++) {
- STORAGE_ENGINE *eng = qn->rrdhost->db[tier].eng;
- tier_retention[tier].eng = eng;
+ for (size_t tier = 0; tier < rrdb.storage_tiers; tier++) {
+ STORAGE_ENGINE_ID storage_engine_id = qn->rrdhost->db[tier].id;
+ tier_retention[tier].storage_engine_id = storage_engine_id;
tier_retention[tier].db_update_every_s = (time_t) (qn->rrdhost->db[tier].tier_grouping * ri->update_every_s);
if(rm->rrddim && rm->rrddim->tiers[tier].db_metric_handle)
- tier_retention[tier].db_metric_handle = eng->api.metric_dup(rm->rrddim->tiers[tier].db_metric_handle);
+ tier_retention[tier].db_metric_handle = storage_engine_metric_dup(rm->rrddim->rrdset->storage_engine_id, rm->rrddim->tiers[tier].db_metric_handle);
else
- tier_retention[tier].db_metric_handle = eng->api.metric_get(qn->rrdhost->db[tier].instance, &rm->uuid);
+ tier_retention[tier].db_metric_handle = storage_engine_metric_get(qn->rrdhost->db[tier].id, qn->rrdhost->db[tier].instance, &rm->uuid);
if(tier_retention[tier].db_metric_handle) {
- tier_retention[tier].db_first_time_s = storage_engine_oldest_time_s(tier_retention[tier].eng->backend, tier_retention[tier].db_metric_handle);
- tier_retention[tier].db_last_time_s = storage_engine_latest_time_s(tier_retention[tier].eng->backend, tier_retention[tier].db_metric_handle);
+ tier_retention[tier].db_first_time_s = storage_engine_oldest_time_s(tier_retention[tier].storage_engine_id, tier_retention[tier].db_metric_handle);
+ tier_retention[tier].db_last_time_s = storage_engine_latest_time_s(tier_retention[tier].storage_engine_id, tier_retention[tier].db_metric_handle);
if(!common_first_time_s)
common_first_time_s = tier_retention[tier].db_first_time_s;
@@ -285,7 +285,7 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
}
}
- for (size_t tier = 0; tier < storage_tiers; tier++) {
+ for (size_t tier = 0; tier < rrdb.storage_tiers; tier++) {
if(!qt->db.tiers[tier].update_every || (tier_retention[tier].db_update_every_s && tier_retention[tier].db_update_every_s < qt->db.tiers[tier].update_every))
qt->db.tiers[tier].update_every = tier_retention[tier].db_update_every_s;
@@ -329,8 +329,8 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
if (!qt->db.last_time_s || common_last_time_s > qt->db.last_time_s)
qt->db.last_time_s = common_last_time_s;
- for (size_t tier = 0; tier < storage_tiers; tier++) {
- internal_fatal(tier_retention[tier].eng != query_metric_storage_engine(qt, qm, tier), "QUERY TARGET: storage engine mismatch");
+ for (size_t tier = 0; tier < rrdb.storage_tiers; tier++) {
+ internal_fatal(tier_retention[tier].storage_engine_id != query_metric_storage_engine(qt, qm, tier), "QUERY TARGET: storage engine mismatch");
qm->tiers[tier].db_metric_handle = tier_retention[tier].db_metric_handle;
qm->tiers[tier].db_first_time_s = tier_retention[tier].db_first_time_s;
qm->tiers[tier].db_last_time_s = tier_retention[tier].db_last_time_s;
@@ -341,9 +341,9 @@ static bool query_metric_add(QUERY_TARGET_LOCALS *qtl, QUERY_NODE *qn, QUERY_CON
}
// cleanup anything we allocated to the retention we will not use
- for(size_t tier = 0; tier < storage_tiers ;tier++) {
+ for(size_t tier = 0; tier < rrdb.storage_tiers ;tier++) {
if (tier_retention[tier].db_metric_handle)
- tier_retention[tier].eng->api.metric_release(tier_retention[tier].db_metric_handle);
+ storage_engine_metric_release(tier_retention[tier].storage_engine_id, tier_retention[tier].db_metric_handle);
}
return false;
diff --git a/database/contexts/rrdcontext.c b/database/contexts/rrdcontext.c
index 8538d17f28..fe52a0f6ae 100644
--- a/database/contexts/rrdcontext.c
+++ b/database/contexts/rrdcontext.c
@@ -199,25 +199,8 @@ int rrdcontext_foreach_instance_with_rrdset_in_context(RRDHOST *host, const char
// ACLK interface
static bool rrdhost_check_our_claim_id(const char *claim_id) {
- if(!localhost->aclk_state.claimed_id) return false;
- return (strcasecmp(claim_id, localhost->aclk_state.claimed_id) == 0) ? true : false;
-}
-
-static RRDHOST *rrdhost_find_by_node_id(const char *node_id) {
- uuid_t uuid;
- if (uuid_parse(node_id, uuid))
- return NULL;
-
- RRDHOST *host = NULL;
- dfe_start_read(rrdhost_root_index, host) {
- if(!host->node_id) continue;
-
- if(uuid_memcmp(&uuid, host->node_id) == 0)
- break;
- }
- dfe_done(host);
-
- return host;
+ if(!rrdb.localhost->aclk_state.claimed_id) return false;
+ return (strcasecmp(claim_id, rrdb.localhost->aclk_state.claimed_id) == 0) ? true : false;
}
void rrdcontext_hub_checkpoint_command(void *ptr) {
@@ -226,7 +209,7 @@ void rrdcontext_hub_checkpoint_command(void *ptr) {
if(!rrdhost_check_our_claim_id(cmd->claim_id)) {
netdata_log_error("RRDCONTEXT: received checkpoint command for claim_id '%s', node id '%s', but this is not our claim id. Ours '%s', received '%s'. Ignoring command.",
cmd->claim_id, cmd->node_id,
- localhost->aclk_state.claimed_id?localhost->aclk_state.claimed_id:"NOT SET",
+ rrdb.localhost->aclk_state.claimed_id ? rrdb.localhost->aclk_state.claimed_id : "NOT SET",
cmd->claim_id);
return;
@@ -288,7 +271,7 @@ void rrdcontext_hub_stop_streaming_command(void *ptr) {
if(!rrdhost_check_our_claim_id(cmd->claim_id)) {
netdata_log_error("RRDCONTEXT: received stop streaming command for claim_id '%s', node id '%s', but this is not our claim id. Ours '%s', received '%s'. Ignoring command.",
cmd->claim_id, cmd->node_id,
- localhost->aclk_state.claimed_id?localhost->aclk_state.claimed_id:"NOT SET",
+ rrdb.localhost->aclk_state.claimed_id ? rrdb.localhost->aclk_state.claimed_id : "NOT SET",
cmd->claim_id);
return;
diff --git a/database/contexts/rrdcontext.h b/database/contexts/rrdcontext.h
index e3a1ab9afc..829a4f2b33 100644
--- a/database/contexts/rrdcontext.h
+++ b/database/contexts/rrdcontext.h
@@ -577,7 +577,7 @@ static inline const char *query_metric_name(QUERY_TARGET *qt, QUERY_METRIC *qm)
return rrdmetric_acquired_name(qd->rma);
}
-struct storage_engine *query_metric_storage_engine(QUERY_TARGET *qt, QUERY_METRIC *qm, size_t tier);
+STORAGE_ENGINE_ID query_metric_storage_engine(QUERY_TARGET *qt, QUERY_METRIC *qm, size_t tier);
STRING *query_instance_id_fqdn(QUERY_INSTANCE *qi, size_t version);
STRING *query_instance_name_fqdn(QUERY_INSTANCE *qi, size_t version);
diff --git a/database/contexts/worker.c b/database/contexts/worker.c
index e6c3ff3df4..c10cb7c241 100644
--- a/database/contexts/worker.c
+++ b/database/contexts/worker.c
@@ -216,7 +216,7 @@ void rrdcontext_recalculate_host_retention(RRDHOST *host, RRD_FLAGS reason, bool
static void rrdcontext_recalculate_retention_all_hosts(void) {
rrdcontext_next_db_rotation_ut = 0;
RRDHOST *host;
- dfe_start_reentrant(rrdhost_root_index, host) {
+ dfe_start_reentrant(rrdb.rrdhost_root_index, host) {
worker_is_busy(WORKER_JOB_RETENTION);
rrdcontext_recalculate_host_retention(host, RRD_FLAG_UPDATE_REASON_DB_ROTATION, true);
}
@@ -235,11 +235,9 @@ bool rrdmetric_update_retention(RRDMETRIC *rm) {
}
else {
RRDHOST *rrdhost = rm->ri->rc->rrdhost;
- for (size_t tier = 0; tier < storage_tiers; tier++) {
- STORAGE_ENGINE *eng = rrdhost->db[tier].eng;
-
+ for (size_t tier = 0; tier < rrdb.storage_tiers; tier++) {
time_t first_time_t, last_time_t;
- if (eng->api.metric_retention_by_uuid(rrdhost->db[tier].instance, &rm->uuid, &first_time_t, &last_time_t)) {
+ if (storage_engine_metric_retention(rrdhost->db[tier].id, rrdhost->db[tier].instance, &rm->uuid, &first_time_t, &last_time_t)) {
if (first_time_t < min_first_time_t)
min_first_time_t = first_time_t;
@@ -436,7 +434,7 @@ static void rrdcontext_garbage_collect_single_host(RRDHOST *host, bool worker_jo
static void rrdcontext_garbage_collect_for_all_hosts(void) {
RRDHOST *host;
- dfe_start_reentrant(rrdhost_root_index, host) {
+ dfe_start_reentrant(rrdb.rrdhost_root_index, host) {
rrdcontext_garbage_collect_single_host(host, true);
}
dfe_done(host);
@@ -1104,7 +1102,7 @@ void *rrdcontext_main(void *ptr) {
size_t pp_queued_contexts_for_all_hosts = 0;
RRDHOST *host;
- dfe_start_reentrant(rrdhost_root_index, host) {
+ dfe_start_reentrant(rrdb.rrdhost_root_index, host) {
if(unlikely(!service_running(SERVICE_CONTEXT))) break;
worker_is_busy(WORKER_JOB_HOSTS);
diff --git a/database/engine/cache.c b/database/engine/cache.c
index 7a9ccf8d1b..dbcd00ec31 100644
--- a/database/engine/cache.c
+++ b/database/engine/cache.c
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
#include "cache.h"
/* STATES AND TRANSITIONS
diff --git a/database/engine/cache.h b/database/engine/cache.h
index 1486fdc166..3e440ca83d 100644
--- a/database/engine/cache.h
+++ b/database/engine/cache.h
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
#ifndef DBENGINE_CACHE_H
#define DBENGINE_CACHE_H
diff --git a/database/engine/datafile.c b/database/engine/datafile.c
index d5c1285be1..dd3461e084 100644
--- a/database/engine/datafile.c
+++ b/database/engine/datafile.c
@@ -250,7 +250,7 @@ int create_data_file(struct rrdengine_datafile *datafile)
char path[RRDENG_PATH_MAX];
generate_datafilepath(datafile, path, sizeof(path));
- fd = open_file_for_io(path, O_CREAT | O_RDWR | O_TRUNC, &file, use_direct_io);
+ fd = open_file_for_io(path, O_CREAT | O_RDWR | O_TRUNC, &file, rrdb.use_direct_io);
if (fd < 0) {
ctx_fs_error(ctx);
return fd;
@@ -333,7 +333,7 @@ static int load_data_file(struct rrdengine_datafile *datafile)
char path[RRDENG_PATH_MAX];
generate_datafilepath(datafile, path, sizeof(path));
- fd = open_file_for_io(path, O_RDWR, &file, use_direct_io);
+ fd = open_file_for_io(path, O_RDWR, &file, rrdb.use_direct_io);
if (fd < 0) {
ctx_fs_error(ctx);
return fd;
diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c
index 24d3c1c6d6..5485bb3a99 100644
--- a/database/engine/journalfile.c
+++ b/database/engine/journalfile.c
@@ -296,8 +296,8 @@ static bool journalfile_v2_mounted_data_unmount(struct rrdengine_journalfile *jo
void journalfile_v2_data_unmount_cleanup(time_t now_s) {
// DO NOT WAIT ON ANY LOCK!!!
- for(size_t tier = 0; tier < (size_t)storage_tiers ;tier++) {
- struct rrdengine_instance *ctx = multidb_ctx[tier];
+ for (size_t tier = 0; tier < rrdb.storage_tiers; tier++) {
+ struct rrdengine_instance *ctx = (struct rrdengine_instance *) rrdb.multidb_ctx[tier];
if(!ctx) continue;
struct rrdengine_datafile *datafile;
@@ -577,7 +577,7 @@ int journalfile_create(struct rrdengine_journalfile *journalfile, struct rrdengi
char path[RRDENG_PATH_MAX];
journalfile_v1_generate_path(datafile, path, sizeof(path));
- fd = open_file_for_io(path, O_CREAT | O_RDWR | O_TRUNC, &file, use_direct_io);
+ fd = open_file_for_io(path, O_CREAT | O_RDWR | O_TRUNC, &file, rrdb.use_direct_io);
if (fd < 0) {
ctx_fs_error(ctx);
return fd;
@@ -917,7 +917,7 @@ static int journalfile_v2_validate(void *data_start, size_t journal_v2_file_size
rc = journalfile_check_v2_extent_list(data_start, journal_v2_file_size);
if (rc) return 1;
- if (!db_engine_journal_check)
+ if (!rrdb.db_engine_journal_check)
return 0;
rc = journalfile_check_v2_metric_list(data_start, journal_v2_file_size);
@@ -1115,7 +1115,7 @@ int journalfile_v2_load(struct rrdengine_instance *ctx, struct rrdengine_journal
// Initialize the journal file to be able to access the data
- if (!db_engine_journal_check)
+ if (!rrdb.db_engine_journal_check)
journalfile->v2.flags |= JOURNALFILE_FLAG_METRIC_CRC_CHECK;
journalfile_v2_data_set(journalfile, fd, data_start, journal_v2_file_size);
@@ -1501,7 +1501,7 @@ int journalfile_load(struct rrdengine_instance *ctx, struct rrdengine_journalfil
journalfile_v1_generate_path(datafile, path, sizeof(path));
- fd = open_file_for_io(path, O_RDWR, &file, use_direct_io);
+ fd = open_file_for_io(path, O_RDWR, &file, rrdb.use_direct_io);
if (fd < 0) {
ctx_fs_error(ctx);
diff --git a/database/engine/metric.c b/database/engine/metric.c
index 1370f9d7af..c447577ee3 100644
--- a/database/engine/metric.c
+++ b/database/engine/metric.c
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
#include "metric.h"
typedef int32_t REFCOUNT;
diff --git a/database/engine/metric.h b/database/engine/metric.h
index 5cb5b045e2..40abb6d57d 100644
--- a/database/engine/metric.h
+++ b/database/engine/metric.h
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
#ifndef DBENGINE_METRIC_H
#define DBENGINE_METRIC_H