New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve cleanup scripts #12906
Improve cleanup scripts #12906
Conversation
This pull request has been mentioned on LibreNMS Community. There might be relevant details there: https://community.librenms.org/t/polling-stops-every-day-during-daily-sh-run/15805/6 |
updated Are there integration tests for the daily.sh script? |
includes/functions.php
Outdated
@@ -2056,9 +2057,16 @@ function lock_and_purge($table, $sql) | |||
|
|||
$name = str_replace('_', ' ', ucfirst($table)); | |||
if (is_numeric($purge_days)) { | |||
if (dbDelete($table, $sql, [$purge_days])) { | |||
echo "$name cleared for entries over $purge_days days\n"; | |||
if (is_numeric($count)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI $count is always numeric, you said it must be an int in the parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, removed the check
after running this a few days in production, I see the loop creates a sort of race condition on certain tables that are updated frequently (device_perf). Any of the SQL statements that use I'm thinking I can update each of the SQL statements passed to the
I'm leaning toward option 2 - suggestions? |
2 seems like the better choice, a fixed time instead of a rolling window. |
Closing due to inactivity |
update
lock_and_purge
shared function to do dbDelete in blocks of 1000 rows, similar to how the cleanup forsyslog
currently happensDO NOT DELETE THE UNDERLYING TEXT
Please note
Testers
If you would like to test this pull request then please run:
./scripts/github-apply <pr_id>
, i.e./scripts/github-apply 5926
After you are done testing, you can remove the changes with
./scripts/github-remove
. If there are schema changes, you can ask on discord how to revert.