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

Ad Hoc tasks not running in nextruntime order

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.1.6
    • Tasks
    • None
    • MOODLE_401_STABLE

      I have a plugin I am developing which creates about 20 Ad Hoc tasks in quick succession. Each task has the same component and classname, but different customdata. I have an order I would like them to start running in, and ticket MDL-67980 says that the core code was changed so that they will run in order of nextruntime. Therefore when I create the tasks, I use the set_next_run_time() function to give them next_run_times at 1 second intervals. I have checked the database, and confirmed that the nextruntime is being set as per the above.
       
      What I am then seeing is, when a new Cron runner starts, it correctly picks the Ad Hoc task with the earliest nextruntime. However, when this tasks is completed, that Cron runner then picks an apparently random task from the queue to do next. And then all its subsequent picks are also apparently random.
       
      When a second Cron runner starts, it does the same thing. It's first pick is the Ad Hoc Task with the earliest run time, but subsequent picks are apparently random. And the same applies for the third Cron runner, etc.
       
      I've had a look at the code, but I can't see an obvious reason for this. The function used to select the first Ad Hoc task to run is the same function as is used to select subsequent Ad Hoc tasks.

            Unassigned Unassigned
            DavidNorman99 David Norman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

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