Do not load/save context data in RAM mode (#18790)
Do not load/save context data if db is not dbengine
Stelios Fragkakis committed
Oct 23, 2024 at 11:31 UTC
c92eb0e8322b9f64c182423a5b260e74d704ab2b
1 file changed
+13
-2
src/database/contexts/worker.c
+13
-2
@@ -102,6 +102,9 @@ void rrdhost_load_rrdcontext_data(RRDHOST *host) {
102
if(host->rrdctx.contexts) return;
103
104
rrdhost_create_rrdcontexts(host);
105
+ if (host->rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE)
106
+ return;
107
+
108
ctx_get_context_list(&host->host_id.uuid, rrdcontext_load_context_callback, host);
109
ctx_get_chart_list(&host->host_id.uuid, rrdinstance_load_chart_callback, host);
110
@@ -358,6 +361,9 @@ void rrdcontext_delete_from_sql_unsafe(RRDCONTEXT *rc) {
361
rc->hub.units = string2str(rc->units);
362
rc->hub.family = string2str(rc->family);
363
364
+ if (rc->rrdhost->rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE)
365
+ return;
366
+
367
// delete it from SQL
368
if(ctx_delete_context(&rc->rrdhost->host_id.uuid, &rc->hub) != 0)
369
netdata_log_error("RRDCONTEXT: failed to delete context '%s' version %"PRIu64" from SQL.",
@@ -855,8 +861,13 @@ void rrdcontext_message_send_unsafe(RRDCONTEXT *rc, bool snapshot __maybe_unused
861
if(rrd_flag_is_deleted(rc))
862
rrdcontext_delete_from_sql_unsafe(rc);
863
858
- else if (ctx_store_context(&rc->rrdhost->host_id.uuid, &rc->hub) != 0)
859
- netdata_log_error("RRDCONTEXT: failed to save context '%s' version %"PRIu64" to SQL.", rc->hub.id, rc->hub.version);
864
+ else {
865
+ if (rc->rrdhost->rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE)
866
+ return;
867
+ if (ctx_store_context(&rc->rrdhost->host_id.uuid, &rc->hub) != 0)
868
+ netdata_log_error(
869
+ "RRDCONTEXT: failed to save context '%s' version %" PRIu64 " to SQL.", rc->hub.id, rc->hub.version);
870
+ }
871
}
872
873
static bool check_if_cloud_version_changed_unsafe(RRDCONTEXT *rc, bool sending __maybe_unused) {