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

Moodle upgrade resets scheduled tasks lastruntime

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • master_MDL-70520
    • Hide

      1) Run scheduled task:

      php  admin/cli/scheduled_task.php --execute='\mod_assign\task\cron_task'
      

      2) Confirm, that lastruntime is set for the task:

      moodle=# select lastruntime from mdl_task_scheduled where component = 'mod_assign';
       lastruntime 
       -------------
       1608536830
       (1 row)
      

      3) Increment version number for the mod_assign plugin.

      4) Run upgrade from CLI:

      php admin/cli/upgrade.php
      

      5) Confirm, that lastruntime hasn't been reset:

      moodle=# select lastruntime from mdl_task_scheduled where component = 'mod_assign';
       lastruntime 
       -------------
       1608536830
       (1 row)
      

      Show
      1) Run scheduled task: php admin/cli/scheduled_task.php --execute= '\mod_assign\task\cron_task' 2) Confirm , that lastruntime is set for the task: moodle=# select lastruntime from mdl_task_scheduled where component = 'mod_assign' ; lastruntime ------------- 1608536830 ( 1 row) 3) Increment version number for the mod_assign  plugin. 4) Run upgrade from CLI: php admin/cli/upgrade.php 5) Confirm , that lastruntime hasn't been reset: moodle=# select lastruntime from mdl_task_scheduled where component = 'mod_assign' ; lastruntime ------------- 1608536830 ( 1 row)

      Upgrade script resets scheduled tasks.

      As part of this reset `nextruntime` is kept, but `lastruntime` is being set to 0.

      This can lead to some issues. For example `\mod_assign\task\cron_task` task checks its last time run https://github.com/moodle/moodle/blob/4ec279a2f063ae890804126e4886f87fe83b5cea/mod/assign/locallib.php#L2521 and then selects records to be processed based on returned value:  https://github.com/moodle/moodle/blob/4ec279a2f063ae890804126e4886f87fe83b5cea/mod/assign/locallib.php#L2696-L2697 so when lastruntime equals 0, the task gets all records including those ones which were already processed as part of previous runs.

       

            mikhailgolenkov Misha Golenkov
            mikhailgolenkov Misha Golenkov
            Brendan Heywood Brendan Heywood
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.