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

A bad gradebook formula can have huge impact on opening/closing quizzes

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.8.6, 2.9.1
    • None
    • Gradebook
    • None
    • MOODLE_28_STABLE, MOODLE_29_STABLE

    Description

      If there is a (presumably unknown) error in a gradebook formula, e.g. it references a deleted activity item, there can be a massive impact on the performance of quizzes (at least their opening and closing) in the same course, with no indication of the cause of the problem. I have had this occur twice. On one occasion two affected quizzes were taking up to a minute to open. On another occasion there was a delay of just a few seconds but this had a major impact at the end of an exam when 200 quizzes were auto-closed and the system essentially crashed, with a large number of database errors.

      It appears that when the quiz is opened, a call is made on the gradebook to get a gradebook summary (perhaps to get the number of students who have attempted the quiz?). If the gradebook detects errors in the grades, a forced regarding takes place, which is what takes the time. Also, during this regrading, there is associated database locking, leading to database deadlock and lock timeout errors in the error log under load. Since the forced regrading is unable to resolve the underlying problem, the regrading re-occurs on every opening of the quiz.

      Although it might seem strange to be operating a course with a gradebook formula error, it occurs very easily, particularly when importing courses from a previous year and deleting some of the unwanted activities without being aware there are formulae referencing them.

      Steps to reproduce

      1. Pick a course with plenty of quizzes and at least a couple of hundred students, with grades recorded for the quizzes.
      2. Create a new quiz
      3. Open the gradebook and edit the calculation formula for the total of all quizzes to explicitly reference the newly created quiz (and the others) by giving all quizzes specific ids.
      4. Delete the new quiz. This breaks the quiz-total formula, and if you were to go back to the gradebook you'd find that the deleted grade item appears as something like ##gi<someid>##.
      5. Open any quiz and observe the delay.

      Other observations

      One of the disturbing aspects of this issue is that there is no evidence of the problem in the error logs, even with full logging on, until database errors occur, at which point valuable data may have been lost. I would suggest that when the gradebook module detects formula errors it should log them at a debug level, so a system administrator can be made aware of the underlying problem.

      With a delay of up to a minute occurring in one case, I'm guessing that the gradebook is attempting to regrade all students in the class. If so, is this an appropriate behaviour, once a formula error has been detected? Are they not all doomed to fail too? It seems particularly inappropriate to attempt to regrade the entire class when just a single student is trying to open a quiz.

      In the affected versions below, I have picked 2.8.6 for the second version, although I'm actually running 2.8.1 (not listed). I have checked the problem persists on 2.9.1, however, so I assume it's in 2.8.6 too. [Perhaps I should have picked "2.8 regressions" but I'm unfamiliar with that particular use of the term "regressions"].

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              trampgeek Richard Lobb
              Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              5 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated: