Moodle
  1. Moodle
  2. MDL-34109

Cron task never finishes. Gets to line 'Looking for quiz overdue quiz attempts between Wednesday, 31 December 1969, 6:00 PM...' then never advances

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3.1
    • Component/s: Quiz
    • Labels:

      Description

      Recent upgrade to Moodle 2.3. Set 'When time expires' to 'open attempts are submitted automatically'.

      The cron job has been allowed to run for ~four hours and does not advance. As you trace it, the problem seems to hit an endless loop in 'question/engine/questionusage.php' in the loop (line 716):

      while ($record && $record->qubaid == $qubaid && !is_null($record->slot)) {
      $quba->questionattempts[$record->slot] =
      question_attempt::load_from_records($records,
      $record->questionattemptid, $quba->observer,
      $quba->get_preferred_behaviour());
      if ($records->valid())

      { $record = $records->current(); }

      else

      { $record = false; }

      }

      When I have it spit out the value of '$record', it seems to end up in an endless loop caused by a missing question. It never leaves this loop. It sets $record to the same value forever, never able to leave the loop.

      stdClass Object
      (
      [qubaid] => 26856
      [contextid] => 15506
      [component] => mod_quiz
      [preferredbehaviour] => adaptivenopenalty
      [questionattemptid] => 257042
      [questionusageid] => 26856
      [slot] => 12
      [behaviour] => adaptivenopenalty
      [questionid] => 0
      [variant] => 1
      [maxmark] => 1.0000000
      [minfraction] => 0.0000000
      [flagged] => 0
      [questionsummary] => This question is missing. Unable to display anything.
      [rightanswer] =>
      [responsesummary] =>
      [timemodified] => 0
      [attemptstepid] =>
      [sequencenumber] =>
      [state] =>
      [fraction] =>
      [timecreated] =>
      [userid] =>
      [name] =>
      [value] =>
      )

      It seems like the loop needs a check for missing questions.

      Let me know if I can provide further information. Seems to be the same problem as: http://moodle.org/mod/forum/discuss.php?d=205668

        Gliffy Diagrams

        1. mdl_quiz_attempts.csv
          299 kB
          Peter Svec
        2. mdl_quiz_attempts.csv
          299 kB
          Peter Svec
        3. mdl_quiz_attempts.csv
          299 kB
          Peter Svec
        4. mdl_quiz_attempts.sql
          282 kB
          Peter Svec
        5. query.txt
          2 kB
          Peter Svec
        6. query.txt
          2 kB
          Peter Svec

          Issue Links

            Activity

            Hide
            Peter Svec added a comment - - edited

            sorry for attaching two times

            Show
            Peter Svec added a comment - - edited sorry for attaching two times
            Hide
            Tim Hunt added a comment -

            Thank you for the data Peter.

            So it looks like there are just 2312 quiz attempt to process, and doing that processing really should not take 10 hours.

            Oh, but more seriously, I think there is a bug in my SQL. The interesting thing is those last two columns, that show the start and end time for the quiz. They are both 0, meaning that the quiz never closes, but we are comparing now() > usertimeclose, which is always true.

            So, all these quizzes without close dates are being flagged as needing processing, so we do a lot of expensive work just to find that actually nothing need to be done.

            I will do a fix for that SQL problem.

            Show
            Tim Hunt added a comment - Thank you for the data Peter. So it looks like there are just 2312 quiz attempt to process, and doing that processing really should not take 10 hours. Oh, but more seriously, I think there is a bug in my SQL. The interesting thing is those last two columns, that show the start and end time for the quiz. They are both 0, meaning that the quiz never closes, but we are comparing now() > usertimeclose, which is always true. So, all these quizzes without close dates are being flagged as needing processing, so we do a lot of expensive work just to find that actually nothing need to be done. I will do a fix for that SQL problem.
            Hide
            Tim Hunt added a comment -

            This SQL change makes the process a lot more efficient, at least in the reporter's case. Whether it solves this performance problem for all large sites remains to be seen.

            If you are trying to review this, note that the change is in two separate comments, so the whitespace changes are separate from the actual code changes.

            Show
            Tim Hunt added a comment - This SQL change makes the process a lot more efficient, at least in the reporter's case. Whether it solves this performance problem for all large sites remains to be seen. If you are trying to review this, note that the change is in two separate comments, so the whitespace changes are separate from the actual code changes.
            Hide
            Dan Poltawski added a comment -

            Integrated, thanks Tim

            Show
            Dan Poltawski added a comment - Integrated, thanks Tim
            Hide
            Stefanos Karasavvidis added a comment -

            Tims patch fixes the issue for me

            Show
            Stefanos Karasavvidis added a comment - Tims patch fixes the issue for me
            Hide
            Adrian Greeve added a comment -

            Tested and found no problems. The cron showed that it had moved off the line 'Looking for quiz attempts between ...'
            Tested a few mdlqa tests:

            Show
            Adrian Greeve added a comment - Tested and found no problems. The cron showed that it had moved off the line 'Looking for quiz attempts between ...' Tested a few mdlqa tests: MDLQA-1466 MDLQA-1468 MDLQA-1472 Test passed
            Hide
            Patrick Mulrooney added a comment -

            Sorry for the slow follow up.

            We tested Tim's fix and unfortunately it does not seem to fix the issue for us.

            I should be able to get some testing data in a day or two, but I believe the process that creates the problem is.

            Create a quiz. Have students take te quiz, but have one of them leave it open. Before running the cron script to close open attempts delete one of the questions. Then try running the script.

            Thanks again for the help.

            Show
            Patrick Mulrooney added a comment - Sorry for the slow follow up. We tested Tim's fix and unfortunately it does not seem to fix the issue for us. I should be able to get some testing data in a day or two, but I believe the process that creates the problem is. Create a quiz. Have students take te quiz, but have one of them leave it open. Before running the cron script to close open attempts delete one of the questions. Then try running the script. Thanks again for the help.
            Hide
            Tim Hunt added a comment -

            Thanks to your report, we found and fixed one problem. If you are still having other problems, please could you create a new tracker issue to continue this? Thanks, and sorry that it is still not working for you.

            Show
            Tim Hunt added a comment - Thanks to your report, we found and fixed one problem. If you are still having other problems, please could you create a new tracker issue to continue this? Thanks, and sorry that it is still not working for you.
            Hide
            Sam Hemelryk added a comment -

            Congratulations your code is upstream - gold star for you!

            This issue + 79 others made it in in time for the minor releases.
            Thank you everyone involved for your exuberant efforts.

            Show
            Sam Hemelryk added a comment - Congratulations your code is upstream - gold star for you! This issue + 79 others made it in in time for the minor releases. Thank you everyone involved for your exuberant efforts.

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: