Grade recalculation locks user's out of assignments

Grade recalculation locks user's out of assignments

by David North -
Number of replies: 7

We have a course that has 1100 students and 46 grade items currently.

When we run a grade recalculation or change a grade item weighting, the server takes a huge hit as it runs a huge amount of DB queries and opens a lot of DB connections. 

We've increased the size of our staging server in order to test this and try resolve the issue. We've increased it to AWS EC2 m4.4xlarge instance (64Gb RAM and 16 2.4 GHz cores). For now it seems to be helping, the site becomes unresponsive for the user that initiated it but that's fine. The problem is that it locks all other user's from accessing assignments. They can navigate the site fine but as soon as you try and open an assignment it just loads and loads.

How can we resolve this as the grade calculations can take hours to complete which is not ideal for our users. We have students all over the world so doing it during off peak hours isn't really an option either as it's always peak for some people.

We are running moodle 2.9. There is a long term plan to upgrade to 3.1 but that won't happen in the next month. Is there any short term solution for now?

Average of ratings: Useful (2)
In reply to David North

Re: Grade recalculation locks user's out of assignments

by David Monllaó -

Hi David,

Ugrading to 3.1 would be nice; sorry I don't have a solution for 2.9, just linking https://tracker.moodle.org/browse/MDL-52002 where we worked on gradebook performance improvements (3.1), you could backport the epic issue's patches to 2.9 although if you do, I would be extremely careful, not only when managing code conflicts but also testing that the behaviour is correct.

Average of ratings: Useful (1)
In reply to David Monllaó

Re: Grade recalculation locks user's out of assignments

by David North -

Thanks David

How would I go about finding and backporting all the epic issue's patches since 2.9?

Sounds like quite a risky process though, but I'm interested to see how much code it involves changing and that will help me assess the risk.

In reply to David North

Re: Grade recalculation locks user's out of assignments

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I suspect that upgrading to 3.1 would be a lower risk strategy and at the end you will have done an upgrade you would have done eventually anyway.

In reply to Marcus Green

Re: Grade recalculation locks user's out of assignments

by David North -
Thanks, I thought as much.
In reply to David North

Re: Grade recalculation locks user's out of assignments

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

One of the noticeable User Interface changes is to assignment grading, so make sure you are comfortable with that before the go on upgrade to 3.1

In reply to Marcus Green

Re: Grade recalculation locks user's out of assignments

by David North -

Thanks for the help Marcus and David

So code wise, we agree it's best to upgrade to 3.1.

And with regards to setting up the gradebook, course settings and site settings. Are there any key setup structures or settings that can be used to help with performance and reduce the amount of processing when doing gradebook edits and calculations. One I've found so far is to disable Grade History. Any other's that you know of that could help with performance?

In reply to David North

Re: Grade recalculation locks user's out of assignments

by Fred Woolard -

I can't say with any certainty that it's directly related, but we had a similar problem with creating test courses in one of our sites (3.0.5). We noticed in another site with same Moodle version, the process would take 30 to 40 minutes to generate a large course, where in another it took in excess of 7 hours. The difference in DB operations was several-fold.

After digging around, and stepping through the code, we could see the difference in the number of DB operations was due to regrading the course and its assignments as each new assignment was added to the test course--because the default aggregation scheme for grade categories was 'Natural' rather than 'Simple Weighted Mean' as was the case in the site that performed well.

If your aggregation scheme in that course happens to be 'Natural' you might try a different scheme to see whether the regrade performs any better.

With a few students in a course, and a reasonable number of assignments, the poor performance of 'Natural' aggregation escapes notice, but there's a tipping point past which regrading with 'Natural' will definitely bog down the system.

Average of ratings: Useful (3)