-
Bug
-
Resolution: Fixed
-
Minor
-
3.7.7, 3.9.1
-
MOODLE_37_STABLE, MOODLE_39_STABLE
-
MOODLE_38_STABLE, MOODLE_39_STABLE
-
master-
MDL-69358 -
One of the reason why backup/restore task can fail is due backup_cleanup_task deletes backupid which are older than loglifetime setting.
After each fail it gets rescheduled and eventually it re-runs once per day. After 30 days (or any other period set in loglifetime setting) `core\task\backup_cleanup_task` deletes the record from mdl_backup_controllers table as it was created more than 30 days ago. After this adhoc tasks fail with `Can't find data record in database table backup_controllers` error. Since that there is nothing we can do with this adhoc tasks. Everything we have is only backipid, but all other details were deleted.
We can enhance `core\task\backup_cleanup_task` core task to skip backup_controllers records and logs which have incompleted backup or restore adhoc tasks.
Steps to replicate (simulate) the issue:
• Enable async backups.
• Create a course.
• Take a backup (initiate).
• Set loglifetime setting to 1 day.
• Change your system time to +2 days from now. Actually, we don't need to simulate failing task, it's enough just leave it.
• Run cleanup task:
php admin/tool/task/cli/schedule_task.php --execute='core\task\backup_cleanup_task'
• Check that mdl_backup_controllers was cleaned up.
• Check that mdl_task_adhoc still has asynchronous_backup_task.
• Run adhoc task:
php admin/tool/task/cli/adhoc_task.php -e
• See how it fails with error "Can't find data record in database table backup_controllers"