Resolve issue on startup in servers with 1 core (#16565)
* Use at least one thread to do context load Check for uninitialized last connected value * Simplify / fix compilation warning
Stelios Fragkakis committed
Dec 7, 2023 at 17:42 UTC
f672c4b0a6d225a9d6e92f84fbfe3f14dd55b332
2 files changed
+8
-1
database/sqlite/sqlite_aclk.c
+6
-1
@@ -80,7 +80,12 @@ static int create_host_callback(void *data, int argc, char **argv, char **column
80
UNUSED(argc);
81
UNUSED(column);
82
83
- time_t last_connected = (time_t) (argv[IDX_LAST_CONNECTED] ? str2uint64_t(argv[IDX_LAST_CONNECTED], NULL) : 0);
83
+ time_t last_connected =
84
+ (time_t)(argv[IDX_LAST_CONNECTED] ? str2uint64_t(argv[IDX_LAST_CONNECTED], NULL) : 0);
85
+
86
+ if (!last_connected)
87
+ last_connected = now_realtime_sec();
88
+
89
time_t age = now_realtime_sec() - last_connected;
90
int is_ephemeral = 0;
91
database/sqlite/sqlite_metadata.c
+2
@@ -1288,6 +1288,8 @@ static void start_all_host_load_context(uv_work_t *req __maybe_unused)
1288
RRDHOST *host;
1289
1290
size_t max_threads = MIN(get_netdata_cpus() / 2, 6);
1291
+ if (max_threads < 1)
1292
+ max_threads = 1;
1293
nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Using %zu threads for context loading", max_threads);
1294
struct host_context_load_thread *hclt = callocz(max_threads, sizeof(*hclt));
1295