lesterchan / wp-dbmanager

Allows you to optimize database, repair database, backup database, restore database, delete backup database , drop/empty tables and run selected queries. Supports automatic scheduling of backing up, optimizing and repairing of database.
https://wordpress.org/plugins/wp-dbmanager/
71 stars 26 forks source link

Daily backup database in WordPress 4.1 is performed multiple times #9

Closed Monter closed 9 years ago

Monter commented 9 years ago

From December 24 DBManager my every moment makes a copy of the database and sends it by e-mail, despite the existence of only one task in WP_Cron. The task set to 13:00 each day is done until 20:00. I can not locate the cause, the server logs there are no errors (eg. Timeout or something similar). WordPress v4.1. Please help.

lesterchan commented 9 years ago

Deactivate the plugin and activate it again. Or better still, uninstall the plugin and install it again?

Alternatively, you can switch to using a real cron https://support.hostgator.com/articles/specialized-help/technical/wordpress/how-to-replace-wordpress-cron-with-a-real-cron-job.

Because the plugin has no control over the WP cron, it just uses the API. This problem is also close to impossible to reproduce which makes it close to impossible to solve.

Monter commented 9 years ago

Why close the thread before it was found the problem? I found the cause. My database has grown strongly, and held the memory_limit setting in php.ini for the CLI was too small, the increase in the limit problem corrects itself. Your plugin does not have an error handler insufficient memory, so when they occur with a cron job is not removed and is trying to perform over and over burdening the server.

lesterchan commented 9 years ago

Sorry about that, I must have click too fast Close and Comment instead of Comment.

If I am not wrong, the WP's Cron once executed will be removed regardless whether or not the outcome is an error. Using Cron it is difficult for the plugin to handle the error message. The only way I can think of is to store it transiently and display it if there is an error.

Nevertheless, I am happy to leave it for now (reopened it). I will add it in when I am free.

If you are feeling adventurous, you can fork my plugin and submit a pull request if you intend to add that feature.

Monter commented 9 years ago

No problem. When I used the copy WP_Cron literally tried to do every now and then what killed the server. I went to a regular cron every 30 minutes and turned off the WP_Cron, but it did not solve the problem. In reference to the server log file wp-cron.php performed with the code 200, which is kind of correct. It was only by the action of PHP redirect to a file and the message revealed the problem:

PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 3200 bytes) in /server_path/my_site/wp-load.php on line 55

It seems that the lack of resources and thus not completing the task results in a lack remove it from the list, so that it shall be repeated for effect. One solution would be to delete the job from Cron immediately after it has been developed into a more complex version, you can check whether the last copy enough time has elapsed thus protecting against overload the server, but do not know the WordPress API and do not want to lecture anyone :)

lesterchan commented 9 years ago

From the API point of view, It can't be deleted because it is recurring event. If it get stuck and keep being executed, it seems to be a bug on WordPress cron side though. It should just fire once regardless whether the outcome is an error or not. I am not sure if there is anything on my end I can do to prevent this besides showing the error outcome (if any).

Nevertheless, I will take note of this to see if there is any similar issue crops up. To be honest, this is the first time I heard of this issue (cron job keeps firing)