summaryrefslogtreecommitdiffstats
path: root/database/rrdset.c
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-10-16 23:15:14 +0300
committerGitHub <noreply@github.com>2022-10-16 23:15:14 +0300
commit08cab7222478d06481c070b7f5027ead1c5d2b01 (patch)
treea7089ad0e88f6b14601a5de888c3699dd0af859e /database/rrdset.c
parent70dad7e1263d066319ad13f13ea0c5b39cf664f5 (diff)
Add a thread to asynchronously process metadata updates (#13783)
* Remove old metalog text fle processing * Add metadata event loop * Move functions from sqlite_functions.c to sqlite_metadata.c Queue updates to the metadata event loop Migration to remove unused tables Cleanup unused functions * Queue chart labels to metadata * Store chart labels to metadata * During shutdown, run full speed * Add shutdown prepare Handle SHUTDOWN in the cmd queue function Add worker thread to handle host/chart/dimension metadata doing dictionary traversals * Remove unused RRDIM_FLAG_ACLK Add flags to trigger host/chart/dimension metadata processing * Incremental processing of chart metadata writes * Store host labels * Remove redundant return statements * Change unit tests / cleanup * Fix rescheduling * Schedule chart labels update by setting the RRDSET_FLAG_METADATA_UPDATE flag * Queue commands to update metadata for dimension and host labels * Make sure we do a final scan to store metadata during shutdown (if needed) * Remove unused structures Adjust queue size since we do batch processing of updates without queueing individual messages Remove pragma mmap for now Fix memory leak during sqlite unittest (minor) * Dont update if we are in archive mode * Cleanup * Build entire message payload and store * Initialize worker completion properly * Properly skip host check for pending metadata updates * Report bind param failures Add worker request inside the data payload Initialize variables to silence warnings Rebase on master * Report the chart id (not the dimension) and the dimension id when storing a dimension * Compilation warnings in 32bit * Add DEFINE for the queries * Remove commented out code * * Remove items parameter from unitest * Remove commented out code * sqlite_metadata.h contains only public items * Use sleep_usec instead of usleep * Rename metadata_database_init_cmd_queue to metadata_init_cmd_queue * Rename metadata_database_enq_cmd_noblock to metadata_enq_cmd_noblock
Diffstat (limited to 'database/rrdset.c')
-rw-r--r--database/rrdset.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/database/rrdset.c b/database/rrdset.c
index 67e2bc7245..0ab6c0fde8 100644
--- a/database/rrdset.c
+++ b/database/rrdset.c
@@ -173,10 +173,6 @@ static void rrdset_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v
}
}
- if (find_chart_uuid(host, string2str(st->parts.type), string2str(st->parts.id), string2str(st->parts.name), &st->chart_uuid))
- uuid_generate(st->chart_uuid);
- update_chart_metadata(&st->chart_uuid, st, string2str(st->parts.id), string2str(st->parts.name));
-
// initialize the db tiers
{
RRD_MEMORY_MODE wanted_mode = ctr->memory_mode;
@@ -392,10 +388,14 @@ static void rrdset_react_callback(const DICTIONARY_ITEM *item __maybe_unused, vo
rrdhost_flag_set(st->rrdhost, RRDHOST_FLAG_PENDING_HEALTH_INITIALIZATION);
}
- if(ctr->react_action & (RRDSET_REACT_UPDATED | RRDSET_REACT_PLUGIN_UPDATED | RRDSET_REACT_MODULE_UPDATED)) {
- debug(D_METADATALOG, "CHART [%s] metadata updated", rrdset_id(st));
- if(unlikely(update_chart_metadata(&st->chart_uuid, st, ctr->id, ctr->name)))
- error_report("Failed to update chart metadata in the database");
+ if(ctr->react_action & (RRDSET_REACT_NEW | RRDSET_REACT_PLUGIN_UPDATED | RRDSET_REACT_MODULE_UPDATED)) {
+ if (ctr->react_action & RRDSET_REACT_NEW) {
+ if (find_chart_uuid(host, string2str(st->parts.type), string2str(st->parts.id), &st->chart_uuid)) {
+ uuid_generate(st->chart_uuid);
+ }
+ }
+ rrdset_flag_set(st, RRDSET_FLAG_METADATA_UPDATE);
+ rrdhost_flag_set(st->rrdhost, RRDHOST_FLAG_METADATA_UPDATE);
}
rrdcontext_updated_rrdset(st);