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

If a task fails and is being re-run, temp increase the debugging

XMLWordPrintable

    • MOODLE_401_STABLE
    • MDL-70568-cron-debugging-patch
    • Hide

      Preparation:

      Install tool/testtasks

      git clone git@github.com:catalyst/moodle-tool_testtasks.git admin/tool/testtasks

      The SQL steps below are for mysql, they may need double \ instead of single \ for testing in postgres.

      Adhoc tasks

      1. To test for adhoc tasks: Queue and run adhoc task, setting successrate to 0 so that it consistantly fails

      php admin/tool/testtasks/cli/queue_adhoc_tasks.php -n=1 -s=0
      php admin/cli/adhoc_task.php -e

      2. Check task logs to confirm that the task failed and confirm that debugging is turned off. If debugging is turned off there will be no stack trace ("Backtrace: ...") showing in the task logs.

      Check task log in cli or go to:

      Site Administration > Server > Tasks > Task Logs

      search for 'timed_adhoc_task'

      3. Go into database and set fail delay for timed_adhoc_task to 120 (or greater);

      UPDATE mdl_task_adhoc SET faildelay=120 WHERE classname='\tool_testtasks\task\timed_adhoc_task';

      Repeat steps 2 and 3.

      Confirm that debugging is turned on, check the stack trace ("Backtrace: ...") for the failed timed_adhoc_task is showing.

      4. Go back to the database and clear the fail delay for timed_adhoc_task

      UPDATE mdl_task_adhoc SET faildelay=0 WHERE classname='\tool_testtasks\task\timed_adhoc_task';

      5. Repeat steps 2 and 3 one more time.

      6. Confirm debugging is turned off again, confirm the stacktrace did not show.

      Scheduled Tasks

      1. In the database, reset the fail delay for the scheduled task which will be used for testing

      UPDATE mdl_task_scheduled SET faildelay=0 WHERE classname='\tool_testtasks\task\failing_task';

      2. Run the task

      php admin/cli/scheduled_task.php --execute='\tool_testtasks\task\failing_task'
       
      

      3. Check task logs to confirm that debugging is turned off. If it is turned off there will be no stack trace ("Backtrace: ...") shown for the failing task

      Check in the cli or go to:

      Site Administration > Server > Tasks > Task Logs

      search for 'failing_task'

      4. Go to database and set fail delay for failing_task

      UPDATE mdl_task_scheduled SET faildelay=120 WHERE classname='\tool_testtasks\task\failing_task';

      5. repeat steps 2 and 3. Confirm that debugging is turned on. If it is you will be able to see the stack trace ("Backtrace: ...") for the failed task

      6. Go back to the database and reset the fail delay

      UPDATE mdl_task_scheduled SET faildelay=0 WHERE classname='\tool_testtasks\task\failing_task';

      7. Repeat steps 2 and 3 one more time. Confirm debugging is turned off again by seeing no stack trace ("Backtrace: ...") shown for the failing task.

      Show
      Preparation: Install tool/testtasks git clone git @github .com:catalyst/moodle-tool_testtasks.git admin/tool/testtasks The SQL steps below are for mysql, they may need double \ instead of single \ for testing in postgres. Adhoc tasks 1. To test for adhoc tasks: Queue and run adhoc task, setting successrate to 0 so that it consistantly fails php admin/tool/testtasks/cli/queue_adhoc_tasks.php -n= 1 -s= 0 php admin/cli/adhoc_task.php -e 2. Check task logs to confirm that the task failed and confirm that debugging is turned off. If debugging is turned off there will be no stack trace (" Backtrace: ... ") showing in the task logs . Check task log in cli or go to: Site Administration > Server > Tasks > Task Logs search for 'timed_adhoc_task' 3. Go into database and set fail delay for timed_adhoc_task to 120 (or greater); UPDATE mdl_task_adhoc SET faildelay= 120 WHERE classname= '\tool_testtasks\task\timed_adhoc_task' ; Repeat steps 2 and 3. Confirm that debugging is turned on, check the stack trace (" Backtrace: ... ") for the failed timed_adhoc_task is showing . 4. Go back to the database and clear the fail delay for timed_adhoc_task UPDATE mdl_task_adhoc SET faildelay= 0 WHERE classname= '\tool_testtasks\task\timed_adhoc_task' ; 5. Repeat steps 2 and 3 one more time. 6. Confirm debugging is turned off again, confirm the stacktrace did not show . Scheduled Tasks 1. In the database, reset the fail delay for the scheduled task which will be used for testing UPDATE mdl_task_scheduled SET faildelay= 0 WHERE classname= '\tool_testtasks\task\failing_task' ; 2. Run the task php admin/cli/scheduled_task.php --execute= '\tool_testtasks\task\failing_task' 3. Check task logs to confirm that debugging is turned off. If it is turned off there will be no stack trace (" Backtrace: ... ") shown for the failing task Check in the cli or go to: Site Administration > Server > Tasks > Task Logs search for 'failing_task' 4. Go to database and set fail delay for failing_task UPDATE mdl_task_scheduled SET faildelay= 120 WHERE classname= '\tool_testtasks\task\failing_task' ; 5. repeat steps 2 and 3. Confirm that debugging is turned on. If it is you will be able to see the stack trace (" Backtrace: ... ") for the failed task 6. Go back to the database and reset the fail delay UPDATE mdl_task_scheduled SET faildelay= 0 WHERE classname= '\tool_testtasks\task\failing_task' ; 7. Repeat steps 2 and 3 one more time. Confirm debugging is turned off again by seeing no stack trace (" Backtrace: ... ") shown for the failing task.

      The idea being if it has failed it is more likely to fail again and we want to just gather the info we need up front so its there ready to go.

      I don't want to introduce a lot of complexity here, something simple like this should be enough:

      $CFG->debugcronfaildelay = E_ALL | E_STRICT;

      When cron picks up a task with a delay it will set it to this, and then when it is done it will set it back to what it was. Perhaps to remove some random noise we could only apply this if the faildelay is > 120 so it has 1 opportunity to re-run to completion before we up the debug level.

      There is the existing setting which maybe we can do something funky with:

      $CFG->showcrondebugging = true;

      like:

      $CFG->showcrondebugging = 'auto';

       

       

       

        1. MDL-70568_adhoc_1.png
          MDL-70568_adhoc_1.png
          135 kB
        2. MDL-70568_adhoc_2.png
          MDL-70568_adhoc_2.png
          183 kB
        3. MDL-70568_adhoc_3.png
          MDL-70568_adhoc_3.png
          187 kB
        4. MDL-70568_scheduled_1.png
          MDL-70568_scheduled_1.png
          114 kB
        5. MDL-70568_scheduled_2.png
          MDL-70568_scheduled_2.png
          152 kB
        6. MDL-70568_scheduled_3.png
          MDL-70568_scheduled_3.png
          147 kB

            mikemacgirvin Mike Macgirvin
            brendanheywood Brendan Heywood
            Kevin Pham Kevin Pham
            Jun Pataleta Jun Pataleta
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            3 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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