@cryptotaxi247 / netdata-1 / commits / 80de3046d

Improve metasync shutdown (#20303)

Check if we failed to submit shutdown command

Stelios Fragkakis committed May 19, 2025 at 19:48 UTC 80de3046d090caef71cbf46fa590410f8a60b976
1 file changed +9 -4
src/database/sqlite/sqlite_metadata.c
+9 -4
@@ -2723,12 +2723,17 @@ void metadata_sync_shutdown(void)
2723 {
2724 struct metadata_cmd cmd;
2725 memset(&cmd, 0, sizeof(cmd));
2726 - nd_log_daemon(NDLP_DEBUG, "METADATA: Sending a shutdown command");
2726 cmd.opcode = METADATA_SYNC_SHUTDOWN;
2728 - metadata_enq_cmd(&cmd);
2727
2730 - /* wait for metadata thread to shut down */
2731 - nd_log_daemon(NDLP_DEBUG, "METADATA: Waiting for shutdown ACK");
2728 + // if we can't sent command return
2729 + // This should not happen but if we wait we may not get a completion
2730 + // and shutdown will timeout
2731 + if (!metadata_enq_cmd(&cmd)) {
2732 + nd_log_daemon(NDLP_WARNING, "METADATA: Failed to send a shutdown command");
2733 + return;
2734 + }
2735 + nd_log_daemon(NDLP_INFO, "METADATA: Submitted shutdown command, waiting for ACK");
2736 +
2737 completion_wait_for(&meta_config.start_stop_complete);
2738 completion_destroy(&meta_config.start_stop_complete);
2739