-
Bug
-
Resolution: Fixed
-
Minor
-
2.8.6, 2.9.1
-
5
-
Team Alpha - Planning I2-2024
There seems to be unnecessary grade recalculation of the whole course happening on view quiz page. And we only need the finalgrade of 1 student to notify him that grade is overridden. Depending on various scenarios this might have a huge performance impact (for example when there is an error in calculation formula for some other grade item in gradebook). We only need to pull those grades required.
Old description (for history):
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
- Pick a course with plenty of quizzes and at least a couple of hundred students, with grades recorded for the quizzes.
- Create a new quiz
- 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.
- 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>##.
- 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"].
- has a non-specific relationship to
-
MDL-64681 Better handling of broken (needsupdate = 1) gradebook
- Closed
- Testing discovered
-
MDL-81808 Poor error handling in calculation formula when activity is deleted
- Open
-
MDL-81809 Incorrect handling of regrade error
- Open
-
MDL-81833 Warn user in UI when activity or manual grade item to be deleted is used in calculation formula
- Open
-
MDL-81834 Grade item and activity deletion webservice should warn when item is used in calculation formula
- Open
- will be (partly) resolved by
-
MDL-74449 Error in gradebook with PHP8.0
- Closed
-
MDL-72451 Show regrade error message in the quiz view page
- Closed