Skip to content

Commit

Permalink
Improve metadata cleanup (netdata#19479)
Browse files Browse the repository at this point in the history
* Add workers
Do not delete labels when removing a node
Complete one scan for chart and dimension metadata check

* Fix logs, formatting

* Remove unused function

* Code cleanup

* Fixed missing prepared statement check

* Do checks for vacuum at most every 60 seconds
  • Loading branch information
stelfrag authored Jan 27, 2025
1 parent 74eef8b commit 0329cd4
Show file tree
Hide file tree
Showing 5 changed files with 374 additions and 381 deletions.
4 changes: 4 additions & 0 deletions src/daemon/libuv_workers.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ void register_libuv_worker_jobs() {
worker_register_job_name(UV_EVENT_CTX_CLEANUP, "metadata ctx cleanup");
worker_register_job_name(UV_EVENT_STORE_ALERT_TRANSITIONS, "metadata store alert transitions");
worker_register_job_name(UV_EVENT_CHART_LABEL_CLEANUP, "metadata chart label cleanup");
worker_register_job_name(UV_EVENT_HEALTH_LOG_CLEANUP, "alert transitions cleanup");
worker_register_job_name(UV_EVENT_UUID_DELETION, "metadata dimension deletion");
worker_register_job_name(UV_EVENT_DIMENSION_CLEANUP, "metadata dimension cleanup");
worker_register_job_name(UV_EVENT_CHART_CLEANUP, "metadata chart cleanup");
worker_register_job_name(UV_EVENT_STORE_HOST, "metadata store host");
worker_register_job_name(UV_EVENT_STORE_CHART, "metadata store chart");
worker_register_job_name(UV_EVENT_STORE_DIMENSION, "metadata store dimension");

// aclk_sync
worker_register_job_name(UV_EVENT_ACLK_NODE_INFO, "aclk host node info");
Expand Down
4 changes: 4 additions & 0 deletions src/daemon/libuv_workers.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ enum event_loop_job {
UV_EVENT_METADATA_ML_LOAD,
UV_EVENT_CTX_CLEANUP_SCHEDULE,
UV_EVENT_CTX_CLEANUP,
UV_EVENT_STORE_HOST,
UV_EVENT_STORE_CHART,
UV_EVENT_STORE_DIMENSION,
UV_EVENT_STORE_ALERT_TRANSITIONS,
UV_EVENT_HEALTH_LOG_CLEANUP,
UV_EVENT_CHART_LABEL_CLEANUP,
UV_EVENT_UUID_DELETION,
UV_EVENT_DIMENSION_CLEANUP,
Expand Down
8 changes: 2 additions & 6 deletions src/database/sqlite/sqlite_aclk.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,10 @@ static void sql_unregister_node(char *machine_guid)
param = 0;

rc = sqlite3_step_monitored(res);
if (unlikely(rc != SQLITE_DONE)) {
if (unlikely(rc != SQLITE_DONE))
error_report("Failed to execute command to remove host node id");
} else {
// node: machine guid will be freed after processing
else
invalidate_host_last_connected(&host_uuid);
metadata_delete_host_chart_labels(machine_guid);
machine_guid = NULL;
}

done:
REPORT_BIND_FAIL(res, param);
Expand Down
Loading

0 comments on commit 0329cd4

Please sign in to comment.