diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-10-21 11:02:25 +0300 |
---|---|---|
committer | Tasos Katsoulas <tasos@netdata.cloud> | 2023-10-26 13:33:31 +0300 |
commit | bbf8e320ee544ccbbd64d52355b9d5114f0d95b1 (patch) | |
tree | 33e5a0033ad9d74ce2a29c61e316e69224e1a227 | |
parent | 125aa394bef0d4431d51cd8a4cb5b9a4afa1801b (diff) |
shutdown while waiting for collectors to finish (#16023)
call cleanup_destroyed_dictionaries() while waiting for collectors to finish
(cherry picked from commit babb3c129c4abcf619f221664b88a10914ed493f)
-rw-r--r-- | daemon/main.c | 1 | ||||
-rw-r--r-- | libnetdata/dictionary/dictionary.c | 13 | ||||
-rw-r--r-- | libnetdata/dictionary/dictionary.h | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/daemon/main.c b/daemon/main.c index ab7997969c..5d25f88b5f 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -449,6 +449,7 @@ void netdata_cleanup_and_exit(int ret) { error_limit_static_thread_var(erl, 1, 100 * USEC_PER_MS); error_limit(&erl, "waiting for %zu collectors to finish", running); // sleep_usec(100 * USEC_PER_MS); + cleanup_destroyed_dictionaries(); } } diff --git a/libnetdata/dictionary/dictionary.c b/libnetdata/dictionary/dictionary.c index a74a59583e..2d5313c392 100644 --- a/libnetdata/dictionary/dictionary.c +++ b/libnetdata/dictionary/dictionary.c @@ -137,6 +137,7 @@ struct dictionary { const char *creation_function; const char *creation_file; size_t creation_line; + pid_t creation_tid; #endif usec_t last_gc_run_us; @@ -1873,6 +1874,7 @@ void cleanup_destroyed_dictionaries(void) { size_t line = dict->creation_line; const char *file = dict->creation_file; const char *function = dict->creation_function; + pid_t pid = dict->creation_tid; #endif DICTIONARY_STATS_DICT_DESTROY_QUEUED_MINUS1(dict); @@ -1880,13 +1882,19 @@ void cleanup_destroyed_dictionaries(void) { internal_error( true, - "DICTIONARY: freed dictionary with delayed destruction, created from %s() %zu@%s.", - function, line, file); + "DICTIONARY: freed dictionary with delayed destruction, created from %s() %zu@%s pid %d.", + function, line, file, pid); if(last) last->next = next; else dictionaries_waiting_to_be_destroyed = next; } else { + + internal_error( + true, + "DICTIONARY: cannot free dictionary with delayed destruction, created from %s() %zu@%s pid %d.", + function, line, file, pid); + DICTIONARY_STATS_DICT_DESTROY_QUEUED_PLUS1(dict); last = dict; } @@ -2085,6 +2093,7 @@ DICTIONARY *dictionary_create_view(DICTIONARY *master) { dict->creation_function = function; dict->creation_file = file; dict->creation_line = line; + dict->creation_tid = gettid(); #endif DICTIONARY_STATS_DICT_CREATIONS_PLUS1(dict); diff --git a/libnetdata/dictionary/dictionary.h b/libnetdata/dictionary/dictionary.h index 72efe1d038..391be4ee5b 100644 --- a/libnetdata/dictionary/dictionary.h +++ b/libnetdata/dictionary/dictionary.h @@ -162,6 +162,8 @@ void dictionary_version_increment(DICTIONARY *dict); void dictionary_garbage_collect(DICTIONARY *dict); +void cleanup_destroyed_dictionaries(void); + // ---------------------------------------------------------------------------- // Set an item in the dictionary // |