Better cleanup of aclk alert table entries (#15706)
better cleanup of aclk alert table entries
Emmanuel Vasilakis committed
Aug 2, 2023 at 19:08 UTC
ea911637b9045f7e6ea119ab0e02ceaf8ea0ff26
1 file changed
+2
-2
database/sqlite/sqlite_aclk_alert.c
+2
-2
@@ -7,7 +7,7 @@
7
#include "../../aclk/aclk_alarm_api.h"
8
#endif
9
10
-#define SQL_UPDATE_FILTERED_ALERT "UPDATE aclk_alert_%s SET filtered_alert_unique_id = %u where filtered_alert_unique_id = %u"
10
+#define SQL_UPDATE_FILTERED_ALERT "UPDATE aclk_alert_%s SET filtered_alert_unique_id = %u, date_created = unixepoch() where filtered_alert_unique_id = %u"
11
void update_filtered(ALARM_ENTRY *ae, uint32_t unique_id, char *uuid_str) {
12
char sql[ACLK_SYNC_QUERY_SIZE];
13
snprintfz(sql, ACLK_SYNC_QUERY_SIZE-1, SQL_UPDATE_FILTERED_ALERT, uuid_str, ae->unique_id, unique_id);
@@ -979,7 +979,7 @@ void aclk_push_alert_snapshot_event(char *node_id __maybe_unused)
979
#endif
980
}
981
982
-#define SQL_DELETE_ALERT_ENTRIES "DELETE FROM aclk_alert_%s WHERE filtered_alert_unique_id + %d < UNIXEPOCH();"
982
+#define SQL_DELETE_ALERT_ENTRIES "DELETE FROM aclk_alert_%s WHERE date_created + %d < UNIXEPOCH();"
983
void sql_aclk_alert_clean_dead_entries(RRDHOST *host)
984
{
985
char uuid_str[UUID_STR_LEN];