Cron getting stuck on Awarding badges

Cron getting stuck on Awarding badges

by Heather P -
Number of replies: 11

Hello

I'm on a Moodle 3.8.4 and a Windows server.

My Cron keeps getting stuck. I set it off yesterday from a command line and this is what it started with

Execute scheduled task: Award badges (core\task\badges_cron_task)

... started 16:00:21. Current memory use 7MB.

Started reviewing available badges.

And it hasn't stopped yet. Any thoughts on how I fix it or what is wrong with it?

If I could get it to finish I could disable it in the scheduled task thing, but then we would not award badges. I think its failure coincided with the launch of our very first badge. We hadn't used badges previously.

I'm really not sure what I'm looking for to try to fix.

Thank you for your help.

Heather

Average of ratings: -
In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Aren't you restating https://moodle.org/mod/forum/discuss.php?d=411322 ? It is better to "ping" the old discussion, if you don't get answers rather than scattering it.
In reply to Visvanath Ratnaweera

Re: Cron getting stuck on Awarding badges

by Heather P -
Hi
I didn't think so. The other message is about how to end a cron in general. This is about how to fix a specific section of the cron that seems to be going on forever.
That was a how to stop this is a how to fix. I've narrowed the never ending cron task down to this specific item
I don't know why the 'Award badges' part is not finishing. I found something in the issue tracker that sounded like a possibility https://tracker.moodle.org/browse/MDL-66032 but the bug tracker says it was a Moodle 3.7 and that it is fixed so I'm assuming still fixed in 3.8.
I can't find any useful log files, I can't even work out which courses have badges in order to individually check each course if I have to.

But if it needs merging with the other post, I'm sure someone will.
Thanks
Heather
In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
It could very well be. But there is no way of merging two discussions.

How often do you run cron.php? Can you disable the cron job, kill the running process, raise the https://docs.moodle.org/en/Debugging level to its maximum and then kick cron.php manually once? Then you'll get more clues in the server logs.

Sorry, I don't know how to do that in MS Windows.
In reply to Visvanath Ratnaweera

Re: Cron getting stuck on Awarding badges

by Heather P -
We were running it every five minutes from a scheduled task until it got stuck running one and therefore couldn't start the task. I spent yesterday trying to get it to go manually.
We did manage that and got the run time back down to 81 seconds and I thought all was well.
I then put it back in the scheduled tasks whereupon it started and just wouldn't stop. Forced it to stop again and started it manually and here we are the Award badges is where it is hanging. I've given it 20 hours now in case it was just bottle necked through not running for more than a week, but I don't think it is - I think it just hangs their indefinitely.
I can turn debugging on in the Moodle site but that doesn't seem to connect together with a manually started Cron in the command line on the server.
I can't change the config files on a production server in peak periods very easily as they usually require IIS to be restarted so I'm kind of stuck for the debug at the moment. Currently nothing shows in the php log file. The weird thing is the only thing I'm aware of having changed is actually sending a bade live.

Thank you
In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Does the 'Award badges' task block the remaining tasks in the queue? If so, you'll have to temporarily disable it, either taking it our from the queue or even disabling badges all together, to get the back-log cleared. Otherwise many other areas of Moodle will not function.

I don't know how to do that in a Windows Server. Hope somebody who knows will come to the rescue.
In reply to Visvanath Ratnaweera

Re: Cron getting stuck on Awarding badges

by Heather P -
Hi
Thank you. Yes the Award badges part of the cron does block the rest of the cron. We have disabled it. I used the scheduled task part of Moodle and disabled it there and then set the Windows scheduled task going again. That seems to be fine at the minute for the rest of the cron.
Still struggling with what to do with that part of the cron to make it work again.
One thought is patch Moodle, put a later build of the same version on and see if that magically fixes it. The other is we need to edit that part of the cron so that it gives a useful log file of what is making it stick, but I'm not great at doing that. We have a suspicion about 'has a temp table got corrupted in the database', but again not good at getting to the bottom of that because of the lack of skill at getting out put from the cron.
The other issue of course is this is our live production site which is in heavy use because of the rise in distance learning owing to the pandemic that won't seem to go away, so we can't take it off line too much.
Heather
In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Heather P -
When the cron for awarding badges runs does it populate a temporary table in the database and if it does do we know what it is called?
I'm wondering if we have like a half populated table somewhere?
In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Heather P -
Hi
we have managed to narrow the above down to a specific badge in Moodle that is causing the issue. Disabling the badge seems to make the rest work again.
I just now need to work out what the issue is with the badge.
In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Heather P -
Not sure whether this belongs here or on the badge forum.
When the specific badge is disabled the cron runs, when I re-enable the badge the cron gets stuck. Debug produces nothing.

On a Moodle 3.8 is there a limit to the number of criteria you can attach to a badge? I'm wondering if we have excessive criteria set and it is that causing it to stick, but the badge documentation doesn't say there is a max number of criteria.
Basically my criteria says:-
Complete ALL of:
"URL - Logging On", "URL - ProPortal",
"URL - StartProfile",
"URL - Microsoft 365",
"URL - Microsoft Word",
"URL - Referencing", "URL - Microsoft Outlook",
"URL - OneDrive", "URL - Microsoft Teams",
"URL - Chat", "URL - Posts",
"URL - Likes", "URL - Sessions",
"URL - Class Notebook",
"URL - The iDEA guide",
"Questionnaire - Level 1 - Learning & Feedback",
"Questionnaire - Level 2 - Learning & Feedback ",
"Questionnaire - Level 3 - Learning & Feedback ",
"Questionnaire - Level 4 - Learning & Feedback",
"Questionnaire - Student Digital Training - Learning & Feedback"

15 pieces in total.
Thank you.
Heather
In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Heather,

Unfortunately I can't help with your awarding badges questions, however I am moving your discussion thread from Hardware and performance to the Badges forum where hopefully someone there can help.

In reply to Heather P

Re: Cron getting stuck on Awarding badges

by Darki Tadin-Đurović -
Hi Heather,
I'm throwing an idea here without any specific experience with this and without any argument to back it up. At first glance I'm not too happy when I see ampersands in a criteria list. Could it be that somehow the ampersands creep out of their strings and cause havoc? Unescaped?
Good luck.
Best,
Darki