Closed pixelbrad closed 3 years ago
Not sure if this is intentional, but this query
// Checks if there are any logs older than seven days to delete.
$rows_to_delete_count = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*)
FROM $table_name
WHERE BINARY(%s) < BINARY(DATE_SUB(NOW(), INTERVAL %d DAY))
LIMIT 500",
'log_entry_date',
7
)
);
will return not 500 results but the full number of rows to be pruned. Like I said above, for me, that number was over 800,000.
@pixelbrad Hello! Yes this should be pruning in batches of 500 so the query is incorrect with the LIMIT
there. I released a new version (1.13.7) that addresses this and correctly limits the pruning to 500 logs at a time.
Let me know if this helps with running the cron job manually!
Thanks! Looks good to me. I manually pruned the logs last night with a custom script I whipped up, but I'm sure the changes you've implemented will chunk away just fine.
Fixed in v1.13.7
Hello,
Bit of an edge-case for ya. I recently had a run-in with a plugin where it was attempting to send up to 100 emails every minute non-stop for the past few weeks. I've notified the plugin developers of how this situation arose, and hopefully it doesn't happen again, but it has led to some unintended side-effects. To put it simply, the other plugin I had an issue with led to over 1.15 million failed send attempts to a single address over the last few weeks.
Postmark's cron event to prune log entries older than 7 days,
pm_log_cron_job
, runs once per day. I've attempted to run this cron event manually numerous times, and it's not pruning anything. I've got log entries nearly a month old. I think its not doing anything because its attempting to delete over 800,000 rows from the database in a single transaction, and I assume that's exceeding a limit set somewhere in our infrastructure. Might be worth pruning in chunks if the number of rows to delete is excessively high.This was on a site running latest version of WordPress, latest version of Postmark plugin. Problem plugin was Events Manager / Events Manager Pro. I wrote about my findings to the developers here.
Please let me know if you need anything else from me.
Thanks! Brad