Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-57486

Improve fault tolerance of category and course bin cleanup tasks

    XMLWordPrintable

Details

    • MOODLE_31_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • MOODLE_34_STABLE, MOODLE_35_STABLE
    • master_MDL-57486
    • Easy
    • Hide
      1. Start with a Moodle site with several course categories and courses.
      2. Open Site administration => Courses => Manage courses and categories
      3. Find one of the courses, open the dropdown menu, choose Delete
      4. Under "What to do" choose "Delete all - cannot be undone"
      5. Open Site administration => Plugins => Admin tools => Recycle bin
      6. Modify the lifetime for both of the lifetimes to a few seconds
      7. Wait one minute - we need to wait for the lifetime you configured earlier to pass
      8. Open a console and run

        php admin/tool/task/cli/schedule_task.php --execute="\tool_recyclebin\task\cleanup_category_bin"
        

        1. Confirm that no errors were displayed
      9. Open a course
      10. Create a new Forum activity and add some basic data
      11. Delete the activity
      12. Run the attached runadhoc.php
      13. Open Site administration => Courses => Manage courses and categories
      14. Find the course and delete it
      15. Wait one minute - we need to wait for the lifetime you configured earlier to pass
      16. Open a console and run

        php admin/tool/task/cli/schedule_task.php --execute="\tool_recyclebin\task\cleanup_course_bin"
        

        1. Confirm that no errors were displayed
      Show
      Start with a Moodle site with several course categories and courses. Open Site administration => Courses => Manage courses and categories Find one of the courses, open the dropdown menu, choose Delete Under " What to do " choose " Delete all - cannot be undone " Open Site administration => Plugins => Admin tools => Recycle bin Modify the lifetime for both of the lifetimes to a few seconds Wait one minute - we need to wait for the lifetime you configured earlier to pass Open a console and run php admin/tool/task/cli/schedule_task.php --execute="\tool_recyclebin\task\cleanup_category_bin" Confirm that no errors were displayed Open a course Create a new Forum activity and add some basic data Delete the activity Run the attached runadhoc.php Open Site administration => Courses => Manage courses and categories Find the course and delete it Wait one minute - we need to wait for the lifetime you configured earlier to pass Open a console and run php admin/tool/task/cli/schedule_task.php --execute="\tool_recyclebin\task\cleanup_course_bin" Confirm that no errors were displayed

    Description

      I'm seeing this in my cron output...

      ```
      Scheduled task failed: Cleanup category recycle bin (tool_recyclebin\task\cleanup_category_bin),Can not find data record in database table course_categories.
      Debug info:
      SELECT id,parent FROM

      {course_categories}

      WHERE id = ?
      [array (
      0 => '1255',
      )]
      Backtrace:

      • line 1478 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
      • line 6702 of /lib/accesslib.php: call to moodle_database->get_record()
      • line 291 of /admin/tool/recyclebin/classes/category_bin.php: call to context_coursecat::instance()
      • line 61 of /admin/tool/recyclebin/classes/task/cleanup_category_bin.php: call to tool_recyclebin\category_bin->delete_item()
      • line 75 of /lib/cronlib.php: call to tool_recyclebin\task\cleanup_category_bin->execute()
      • line 81 of /admin/cron.php: call to cron_run()
        ```

      It seems to be looking for a course category in the recycle bin that doesn't exist in the database.

      While this isn't great, isn't it even worse that the task fails because of this? I would have thought it would be better that it registered this issue and then carried on.

      Attachments

        Issue Links

          Activity

            People

              danmarsden Dan Marsden
              howardsmiller Howard Miller
              David Monllaó David Monllaó
              Andrew Lyons Andrew Lyons
              Janelle Barcega Janelle Barcega
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Sujith Haridasan
              Votes:
              21 Vote for this issue
              Watchers:
              27 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Jul/18

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 30 minutes
                  30m