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

Tasks: Implement no-retry flag for ad-hoc tasks and clean up records of historical failed tasks

XMLWordPrintable

    • MOODLE_404_STABLE
    • MDL-79128-main
    • Hide

      Covered by newly created PHPUnit: 

      Make sure all the tests in lib/tests/task/adhoc_task_test.php are passed.
      

       

      Ad hoc tasks report testing

      INSERT INTO mdl_task_adhoc
      (component, classname, nextruntime, faildelay, customdata, userid, blocking, timecreated, timestarted, hostname, pid, attemptsavailable)
      VALUES('core', '\core\task\adhoc_test_task', 1700712047, 0, '{"no":1}', 2, 0, 1700712048, NULL, NULL, NULL, 0);
      INSERT INTO mdl_task_adhoc
      (component, classname, nextruntime, faildelay, customdata, userid, blocking, timecreated, timestarted, hostname, pid, attemptsavailable)
      VALUES('core', '\core\task\adhoc_test2_task', 1700712048, 0, '{"no":2}', 2, 0, 1700712048, NULL, NULL, NULL, 1); 

      1. Use the upper query to insert the data into the task_adhoc table.
      2. Verify that the task_adhoc table now has two new records.
      3. Login as admin.
      4. Navigate to Site Administration > Server > Tasks > Ad hoc tasks.
      5. Verify that you can see as below:
      6. Class name Next run
        adhoc_test_task Never
        adhoc_test2_task ASAP
      1. Remember to delete the two new records in the task_adhoc table.

      New retention setting

      1. Navigate to Site Administration > Server > Tasks > Task processing.
      2. Verify that you will see a new setting called: Failed ad hoc task retention period.
      3. Verify that the short name of that new setting is: task_adhoc_failed_retention.
      4. Verify that the default value of that new setting is: 4 weeks.
      5. Verify that you can change the time to another value. Example: 2 hours.
      6. The logic to handle this value is covered by PHPUnit.

       

       

      Show
      Covered by newly created PHPUnit:   Make sure all the tests in lib/tests/task/adhoc_task_test.php are passed.   Ad hoc tasks report testing INSERT INTO mdl_task_adhoc (component, classname, nextruntime, faildelay, customdata, userid, blocking, timecreated, timestarted, hostname, pid, attemptsavailable) VALUES( 'core' , '\core\task\adhoc_test_task' , 1700712047 , 0 , '{"no":1}' , 2 , 0 , 1700712048 , NULL, NULL, NULL, 0 ); INSERT INTO mdl_task_adhoc (component, classname, nextruntime, faildelay, customdata, userid, blocking, timecreated, timestarted, hostname, pid, attemptsavailable) VALUES( 'core' , '\core\task\adhoc_test2_task' , 1700712048 , 0 , '{"no":2}' , 2 , 0 , 1700712048 , NULL, NULL, NULL, 1 ); Use the upper query to insert the data into the task_adhoc table. Verify that the task_adhoc table now has two new records. Login as admin. Navigate to Site Administration > Server > Tasks > Ad hoc tasks. Verify that you can see as below: Class name Next run adhoc_test_task Never adhoc_test2_task ASAP Remember to delete the two new records in the  task_adhoc table. New retention setting Navigate to Site Administration > Server > Tasks > Task processing. Verify that you will see a new setting called: Failed ad hoc task retention period. Verify that the short name of that new setting is: task_adhoc_failed_retention. Verify that the default value of that new setting is: 4 weeks. Verify that you can change the time to another value. Example: 2 hours. The logic to handle this value is covered by PHPUnit.    
    • 6
    • Team Hedgehog 2023 Sprint 3.3, Team Hedgehog 2023 Review 3, Team Hedgehog 2023 Sprint 4.1, Team Hedgehog 2023 Sprint 4.2, Team Hedgehog 2023 Sprint 4.3

      Not every adhoc task is idempotent and there are times when an adhoc task should not retry when it fails. An example of this is a failed course restore (MDL-75579).

      Ad-hoc tasks should be able to declare that they are "run once", and implement a method (such as allow_retry(): bool) to declare this.

      We should still keep the ability to re-run these tasks from the UI and CLI, as we can for existing ad-hoc tasks. This will help with some recovery and debugging ops for failed tasks.

      We should periodically clean up failed tasks. Currently adhoc task records are removed from the database when they successfully complete. As we will now have permanently failed tasks, these will need to be periodically cleaned up. Possibly reusing the existing metadata cleanup or task log cleanup task (along with the existing retention periods).

            huongn@moodle.com Huong Nguyen
            matt.porritt@moodle.com Matt Porritt
            Stevani Andolo Stevani Andolo
            Ilya Tregubov Ilya Tregubov
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            3 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 week, 4 days, 1 hour, 55 minutes
                1w 4d 1h 55m

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