mirror of
https://github.com/netdata/netdata.git
synced 2025-04-29 23:20:01 +00:00
Improve shutdown when collectors are active (#16315)
* 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:
parent
9d16789341
commit
ca592a9630
2 changed files with 6 additions and 2 deletions
|
@ -440,7 +440,8 @@ void netdata_cleanup_and_exit(int ret) {
|
||||||
delta_shutdown_time("wait for dbengine collectors to finish");
|
delta_shutdown_time("wait for dbengine collectors to finish");
|
||||||
|
|
||||||
size_t running = 1;
|
size_t running = 1;
|
||||||
while(running) {
|
size_t count = 10;
|
||||||
|
while(running && count) {
|
||||||
running = 0;
|
running = 0;
|
||||||
for (size_t tier = 0; tier < storage_tiers; tier++)
|
for (size_t tier = 0; tier < storage_tiers; tier++)
|
||||||
running += rrdeng_collectors_running(multidb_ctx[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);
|
// sleep_usec(100 * USEC_PER_MS);
|
||||||
cleanup_destroyed_dictionaries();
|
cleanup_destroyed_dictionaries();
|
||||||
}
|
}
|
||||||
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
delta_shutdown_time("wait for dbengine main cache to finish flushing");
|
delta_shutdown_time("wait for dbengine main cache to finish flushing");
|
||||||
|
|
|
@ -1241,12 +1241,14 @@ int rrdeng_exit(struct rrdengine_instance *ctx) {
|
||||||
// 4. then wait for completion
|
// 4. then wait for completion
|
||||||
|
|
||||||
bool logged = false;
|
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) {
|
if(!logged) {
|
||||||
netdata_log_info("DBENGINE: waiting for collectors to finish on tier %d...", (ctx->config.legacy) ? -1 : ctx->config.tier);
|
netdata_log_info("DBENGINE: waiting for collectors to finish on tier %d...", (ctx->config.legacy) ? -1 : ctx->config.tier);
|
||||||
logged = true;
|
logged = true;
|
||||||
}
|
}
|
||||||
sleep_usec(100 * USEC_PER_MS);
|
sleep_usec(100 * USEC_PER_MS);
|
||||||
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
netdata_log_info("DBENGINE: flushing main cache for tier %d", (ctx->config.legacy) ? -1 : ctx->config.tier);
|
netdata_log_info("DBENGINE: flushing main cache for tier %d", (ctx->config.legacy) ? -1 : ctx->config.tier);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue