Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

by Paul Lindgreen -
Number of replies: 6
Picture of Particularly helpful Moodlers

moodle 3.5.5+, recycle bin not working after upgrading from moodle 3.3

Deleting a moodle quiz results in a 'Deletion in progress' displayed in the gradebook indefinitely, Never makes it to the Recycle bin.

My test quiz deletion records remain in the mdl_task_adhoc table and the fail delay is increasing.
This table also has 825 records before the recently deleted 2 test quizzes, they have a classname of \core\task\refresh_mod_calendar_events_task and faildelays of 86400,
are they preventing the last two records from running (classname  \core_course\task\course_delete_modules) ?

Can I safely delete the records with faildelays of 86400 from mdl_task_adhoc? All of these records have classname  \core\task\refresh_mod_calendar_events_task .Any downside to calendar events?

I have read another post regarding the recycle bin and the workaround is to remove 'id' data from the mdl_task_adhoc table. Their example is very different from my customdata though
so I was not inclined to try that workaround. Doesn't seem like it will work seeing as I can create the problem by deleting any quiz too.

My mdl_task_adhoc data looks like:
{"cms":"id":"538628","course":"10088","module":"16","instance":"15622","section":"154269","idnumber":"","added":"1561386251","score":"0","indent":"0","visible":"1","visibleoncoursepage":"1","visibleold":"1","groupmode":"0","groupingid":"0","completion":"0","completiongradeitemnumber":null,"completionview":"0","completionexpected":"0","showdescription":"0","availability":null,"deletioninprogress":"1"}],"userid":"7305","realuserid":"7305"}
the 825 calendar event records look like {"courseid":"12564"}
forum post sample looks like:
{"cms":{"52650":{"id":"52650"},"52651":{"id":"52651"},"52652":{"id":"52652"},"52653":{"id":"52653"},"52654":{"id":"52654"},"52655":{"id":"52655"},"52739":{"id":"52739"}},"userid":"3094","realuserid":"3094"}


===error logs=======

Viewing the gradebook does throw a php Warning, not sure if its related:
[26-Jun-2019 09:40:02 ] PHP Warning:  A non-numeric value encountered in .....\grade\report\grader\lib.php on line 489

cronlog entry for recycle bin failure:

Adhoc task failed: core_course\task\course_delete_modules,Coding error detected, it must be fixed by a programmer: The course module 538628 could not be deleted. #0 ....\admin\tool\recyclebin\lib.php(151): tool_recyclebin\course_bin->store_item(Object(stdClass))
#1 ....\course\lib.php(1185): tool_recyclebin_pre_course_module_delete(Object(stdClass))
#2 ....\course\classes\task\course_delete_modules.php(66): course_delete_module('538628')
#3 ....\lib\cronlib.php(185): core_course\task\course_delete_modules->execute()
#4 ....\lib\cronlib.php(74): cron_run_inner_adhoc_task(Object(core_course\task\course_delete_modules))
#5 ....\admin\cli\cron.php(61): cron_run()
#6 {main}

Average of ratings: -
In reply to Paul Lindgreen

Re: Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

The first screenshot of mdl_tasks_adhoc with odd events calendar entries (refresh_mod_calendar_events_task).

The second screenshot is my test activity deletions from this morning. Im also noticing several small backups occurring in my course backup (see 3rd screenshot) area just for this test course, coinciding php error log like the following:
PHP Notice:  Trying to get property of non-object in \backup\util\dbops\backup_plan_dbops.class.php on line 228

Does the first record component=core that has no customdata look correct? Any harm in deleting this record and the other events with faildelays of 86400 ?

mdl_tasks_adhoc refresh_mod_calendar_events_task

m5

m6

In reply to Paul Lindgreen

Re: Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

by Paul Lindgreen -
Picture of Particularly helpful Moodlers
tried deleting records on calendar events from mdl_task_adhoc , didnt solve anything, newly deleted quiz still saying 'deletion in progress' and remains in adhoc table.
stills lots of php notices 'PHP Notice: Trying to get property of non-object in \backup\util\dbops\backup_plan_dbops.class.php on line 228'
and course activity backups still filling up for the test course i am working on ?!
In reply to Paul Lindgreen

Re: Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

by Mark Sharp -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I'm not familiar with the exact error you're getting, but if there's an exception thrown when processing an adhoc task that will cause the fail delay doubling (up to a maximum of 24 hours), and crashing the rest of the cron. 

You'll need to figure out exactly why the error's being thrown. It might be that the thing that's trying to be deleted no longer exists, or there's an actual coding error - perhaps you need to update your plugins.

One thing I've done in the past is change the nextruntime and faildelay values to push the things that are broken out of the way, and let the things that will work do their thing. e.g. change the nextruntime to 1st August 2019 (whatever that is in Unixtime). This buys you time to figure out what's going on without holding up other things.

I have lost a lot of time on this though, it's not very resilient against breakages, so you do need to keep an eye on the adhoc and scheduled task tables.

In reply to Mark Sharp

Re: Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

I deleted the calendar events related records in the task_adhoc table seeing as they had maxed out at 86400 for the fail delay, didnt affect the quiz deletion testing I was doing for the recycle bin though, still 'deletion in progress' in gradebook, never makes it to Recycle bin and the fail delay increasing.

The moodle cron logs do have the same reoccurring errors as follows, which suggests they are runnig and not held up by other adhoc tasks. Anytime I delete a quiz a new module id is added to these cron log errors:

Adhoc task failed: core_course\task\course_delete_modules,Coding error detected, it must be fixed by a programmer: The course module ##### could not be deleted. #0 \admin\tool\recyclebin\lib.php(151): tool_recyclebin\course_bin->store_item(Object(stdClass))

#1 \course\lib.php(1185): tool_recyclebin_pre_course_module_delete(Object(stdClass))
#2 \course\classes\task\course_delete_modules.php(66): course_delete_module('#####')

PHP error logs do have one reoccurring entry (see below) which is vague but interesting, perhaps this id '646308' is the bottle neck for the recycle bin? At the moment Im not sure how to trace down what this id is referring to though, any advice would be appreciated. Im going to pursue this error message next.

Default exception handler: Can not find data record in database table context. Debug: SELECT * FROM {context} WHERE id = ?
[array (
  0 => 646308,
)]

Error code: invalidrecord
* line 1546 of \lib\dml\moodle_database.php: dml_missing_record_exception thrown
* line 1522 of \lib\dml\moodle_database.php: call to moodle_database->get_record_select()
* line 5115 of \lib\accesslib.php: call to moodle_database->get_record()
* line 1178 of \lib\accesslib.php: call to context::instance_by_id()
* line 3998 of \lib\filelib.php: call to get_context_info_array()
* line 40 of \pluginfile.php: call to file_pluginfile()

On a side note, I have previously deleted plugins that had 'missing from disk' messages, I thought that was the source of the problem to begin with, but no luck.



In reply to Paul Lindgreen

Re: Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

by Paul Lindgreen -
Picture of Particularly helpful Moodlers
update: fresh install and getting the problem again, have not uninstalled any plugins.
In reply to Paul Lindgreen

Re: Recycle bin failing, can I delete mdl_task_adhoc records with large fail delay 86400 ?

by Paul Lindgreen -
Picture of Particularly helpful Moodlers
Discovered a Moodle Tracker that appear to describe the problem and solution here:
https://tracker.moodle.org/browse/MDL-65218?attachmentViewMode=list

the issue was related to the course automated backup location, if it was a specific drive the Recycle bin fails, if its the course file area and specific drive it will work as expected.

looks like it was a bug thats fixed post moodle 3.5.5, hoping the next upgrade will remedy the situation
Average of ratings: Useful (1)