make sure all rrdcalcs are unlinked the moment they are deleted (#19893)
Costa Tsaousis committed
Mar 17, 2025 at 21:25 UTC
ace55b6d661d474fff8e11c81fc4671260ca1ded
3 files changed
+11
-1
CMakeLists.txt
+1
@@ -489,6 +489,7 @@ check_function_exists(timegm HAVE_TIMEGM)
489
490
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
491
add_compile_options(-funwind-tables)
492
+ add_compile_options(-fno-omit-frame-pointer)
493
add_link_options(-rdynamic)
494
message(STATUS "Adding -rdynamic (link) and -funwind-tables (compile) for better stack trace support")
495
endif()
src/health/rrdcalc.c
+7
-1
@@ -405,6 +405,7 @@ void rrdcalc_rrdhost_index_init(RRDHOST *host) {
405
}
406
407
void rrdcalc_rrdhost_index_destroy(RRDHOST *host) {
408
+ rrdcalc_delete_all(host);
409
dictionary_destroy(host->rrdcalc_root_index);
410
host->rrdcalc_root_index = NULL;
411
}
@@ -458,7 +459,12 @@ void rrdcalc_unlink_and_delete_all_rrdset_alerts(RRDSET *st) {
459
}
460
461
void rrdcalc_delete_all(RRDHOST *host) {
461
- dictionary_flush(host->rrdcalc_root_index);
462
+ RRDCALC *rc;
463
+ foreach_rrdcalc_in_rrdhost_write(host, rc) {
464
+ rrdcalc_unlink_and_delete(host, rc, false);
465
+ }
466
+ foreach_rrdcalc_in_rrdhost_done(rc);
467
+ dictionary_garbage_collect(host->rrdcalc_root_index);
468
}
469
470
void rrdcalc_child_disconnected(RRDHOST *host) {
src/health/rrdcalc.h
+3
@@ -102,6 +102,9 @@ struct rrdcalc {
102
#define rrdcalc_units(rc) string2str((rc)->config.units)
103
#define rrdcalc_dimensions(rc) string2str((rc)->config.dimensions)
104
105
+#define foreach_rrdcalc_in_rrdhost_write(host, rc) \
106
+ dfe_start_write((host)->rrdcalc_root_index, rc) \
107
+
108
#define foreach_rrdcalc_in_rrdhost_read(host, rc) \
109
dfe_start_read((host)->rrdcalc_root_index, rc) \
110