@cryptotaxi247 / netdata-1 / commits / 5471894ac

Delete from aclk alerts table if ack'ed from cloud one day ago (#11779)

Emmanuel Vasilakis committed Nov 17, 2021 at 09:19 UTC 5471894ac2a4732748ca3133e4d0b3bf3b4fe50e
2 files changed +6
database/sqlite/sqlite_aclk.c
+5
@@ -623,6 +623,11 @@ void sql_maint_aclk_sync_database(struct aclk_database_worker_config *wc, struct
623 "(SELECT unique_id FROM aclk_chart_%s) AND unique_id NOT IN (SELECT unique_id FROM aclk_chart_latest_%s);",
624 wc->uuid_str, wc->uuid_str, wc->uuid_str);
625 db_execute(buffer_tostring(sql));
626 + buffer_flush(sql);
627 +
628 + buffer_sprintf(sql,"DELETE FROM aclk_alert_%s WHERE date_submitted IS NOT NULL AND "
629 + "date_cloud_ack < strftime('%%s','now','-%d seconds');", wc->uuid_str, ACLK_DELETE_ACK_ALERTS_INTERNAL);
630 + db_execute(buffer_tostring(sql));
631
632 buffer_free(sql);
633 return;
database/sqlite/sqlite_aclk.h
+1
@@ -20,6 +20,7 @@
20 #define ACLK_DATABASE_CLEANUP_INTERVAL (3600)
21 #define ACLK_DATABASE_ROTATION_INTERVAL (3600)
22 #define ACLK_DELETE_ACK_INTERNAL (600)
23 +#define ACLK_DELETE_ACK_ALERTS_INTERNAL (86400)
24 #define ACLK_SYNC_QUERY_SIZE 512
25
26 struct aclk_completion {