diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2023-10-18 17:21:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-18 17:21:18 +0300 |
commit | a27aed521f6117fd157e2c599566a4812d9c2dc2 (patch) | |
tree | 52efa4902c60931f8a04411a00434c6c9825b065 /database/sqlite/sqlite_aclk.c | |
parent | 9caea28bcda541558d0adf611a7f69aafed251cc (diff) |
Improve context load on startup (#16203)
* Retrieve last connected timestamp from the database (host->last_connected)
* Improve context load performance
Check for agent shutdown while context load in progress
Log information about host load start and finish
* Remove check for slot as it will only reach this part when a slot is found
Diffstat (limited to 'database/sqlite/sqlite_aclk.c')
-rw-r--r-- | database/sqlite/sqlite_aclk.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/database/sqlite/sqlite_aclk.c b/database/sqlite/sqlite_aclk.c index 1298045c24..effc2c1fa5 100644 --- a/database/sqlite/sqlite_aclk.c +++ b/database/sqlite/sqlite_aclk.c @@ -84,6 +84,7 @@ enum { IDX_PROGRAM_VERSION, IDX_ENTRIES, IDX_HEALTH_ENABLED, + IDX_LAST_CONNECTED, }; static int create_host_callback(void *data, int argc, char **argv, char **column) @@ -127,8 +128,10 @@ static int create_host_callback(void *data, int argc, char **argv, char **column , system_info , 1 ); - if (likely(host)) + if (likely(host)) { host->rrdlabels = sql_load_host_labels((uuid_t *)argv[IDX_HOST_ID]); + host->last_connected = (time_t) (argv[IDX_LAST_CONNECTED] ? str2uint64_t(argv[IDX_LAST_CONNECTED], NULL) : 0); + } (*number_of_chidren)++; @@ -524,7 +527,7 @@ void sql_create_aclk_table(RRDHOST *host __maybe_unused, uuid_t *host_uuid __may #define SQL_FETCH_ALL_HOSTS "SELECT host_id, hostname, registry_hostname, update_every, os, " \ "timezone, tags, hops, memory_mode, abbrev_timezone, utc_offset, program_name, " \ - "program_version, entries, health_enabled FROM host WHERE hops >0;" + "program_version, entries, health_enabled, last_connected FROM host WHERE hops >0;" #define SQL_FETCH_ALL_INSTANCES "SELECT ni.host_id, ni.node_id FROM host h, node_instance ni " \ "WHERE h.host_id = ni.host_id AND ni.node_id IS NOT NULL; " |