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

Moodle upgrade resets scheduled tasks lastruntime

    XMLWordPrintable

Details

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • MOODLE_39_MDL-70520
    • MOODLE_311_MDL-70520
    • 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)

    Description

      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.

       

      Attachments

        Activity

          People

            mikhailgolenkov Misha Golenkov
            mikhailgolenkov Misha Golenkov
            Brendan Heywood Brendan Heywood
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              18/Jan/21

              Time Tracking

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