0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-26 13:54:48 +00:00

Improve shutdown when collectors are active ()

* Collectors should not be running at this point, but allow shutdown to continue after several retries (workaround)

* Proceed with shutdown after 10 attempts
This commit is contained in:
Stelios Fragkakis 2023-11-01 16:22:51 +02:00 committed by GitHub
parent 9d16789341
commit ca592a9630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions
daemon
database/engine

View file

@ -440,7 +440,8 @@ void netdata_cleanup_and_exit(int ret) {
delta_shutdown_time("wait for dbengine collectors to finish");
size_t running = 1;
while(running) {
size_t count = 10;
while(running && count) {
running = 0;
for (size_t tier = 0; tier < storage_tiers; tier++)
running += rrdeng_collectors_running(multidb_ctx[tier]);
@ -451,6 +452,7 @@ void netdata_cleanup_and_exit(int ret) {
// sleep_usec(100 * USEC_PER_MS);
cleanup_destroyed_dictionaries();
}
count--;
}
delta_shutdown_time("wait for dbengine main cache to finish flushing");

View file

@ -1241,12 +1241,14 @@ int rrdeng_exit(struct rrdengine_instance *ctx) {
// 4. then wait for completion
bool logged = false;
while(__atomic_load_n(&ctx->atomic.collectors_running, __ATOMIC_RELAXED) && !unittest_running) {
size_t count = 10;
while(__atomic_load_n(&ctx->atomic.collectors_running, __ATOMIC_RELAXED) && count && !unittest_running) {
if(!logged) {
netdata_log_info("DBENGINE: waiting for collectors to finish on tier %d...", (ctx->config.legacy) ? -1 : ctx->config.tier);
logged = true;
}
sleep_usec(100 * USEC_PER_MS);
count--;
}
netdata_log_info("DBENGINE: flushing main cache for tier %d", (ctx->config.legacy) ? -1 : ctx->config.tier);