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

Better Error handling when core_course\task\course_delete_modules fails

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 3.2.3
    • Backup
    • MOODLE_32_STABLE
    • Hide
      1. Set up a course and delete an assignment with the recycle bin on
      2. Hack an extra unknown setting into the list at backup/util/dbops/backup_controller_dbops.class.php line 617
      3. Run the adhoc task cron. It should pass without error
      Show
      Set up a course and delete an assignment with the recycle bin on Hack an extra unknown setting into the list at backup/util/dbops/backup_controller_dbops.class.php line 617 Run the adhoc task cron. It should pass without error

      Recently I had an issue where hundreds of items had been "marked for deletion" and were not deleting. Upon investigation I found this unhelpful error in the cron debugging:

      Execute adhoc task: core_course\task\course_delete_modules 
      ... started 17:45:06. Current memory use 10.1MB. 
      instantiating backup controller f3804386fb1f367e9249808329542ddc 
      setting controller status to 100 
      loading controller plan 
      setting controller status to 300 
      applying plan defaults 
      setting controller status to 400 
      setting file inclusion to 1 
      checking plan security 
      setting controller status to 700 
      saving controller to db 
      calculating controller checksum c71b6339053f549d06603c988da53e0d 
      loading controller from db 
      notifying plan about excluded activities by type 
      setting controller status to 800 
      setting controller status to 1000 
      saving controller to db 
      Default exception handler: Coding error detected, it must be fixed by a programmer: A lock was created but not released at: 
      [dirroot]/lib/classes/task/manager.php on line 424 
       
      Code should look like: 
       
      $factory = \core\lock\lock_config::get_lock_factory('type'); 
      $lock = $factory->get_lock(Resource id #1940); 
      $lock->release(); // Locks must ALWAYS be released like this. 
       
      Debug: 
      Error code: codingerror 
      * line 117 of /lib/classes/lock/lock.php: coding_exception thrown 
      * line 129 of /lib/cronlib.php: call to core\lock\lock->__destruct() 
      * line 61 of /admin/cli/cron.php: call to cron_run() 
       
      !!! Coding error detected, it must be fixed by a programmer: A lock was created but not released at: 
      [dirroot]/lib/classes/task/manager.php on line 424 
       
      Code should look like: 
       
      $factory = \core\lock\lock_config::get_lock_factory('type'); 
      $lock = $factory->get_lock(Resource id #1940); 
      $lock->release(); // Locks must ALWAYS be released like this. 
       
      !!! 
      !! 
      Error code: codingerror !! 
      !! Stack trace: * line 117 of /lib/classes/lock/lock.php: coding_exception thrown 
      * line 129 of /lib/cronlib.php: call to core\lock\lock->__destruct() 
      * line 61 of /admin/cli/cron.php: call to cron_run() 
      !!

      I was not able to suss out what the issue was based on that debugging, so to the database I went. Looking in the backup_controllers table I could see that Moodle was attempting to back up the same activity over and over again. It happened to be a bad plug-in, which once was removed, resolved the issue. However, this one course module was stopping hundreds of other items from being removed. 

      Would it be possible to a) have this task output more helpful debugging, like perhaps the course module id that it is failing on? and b) have this task handle errors more gracefully and continue with other modules queued for deletion?

            hdagheda Heena Agheda
            heather.williams Heather Williams
            Scott Verbeek Scott Verbeek
            Votes:
            12 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 minutes
                2m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.