CRON lock Error

CRON lock Error

by Stuart Smith -
Number of replies: 9

Hi Everyone 


I am in a pickle, I am not sure how to resolve this issue we are having with our CRON if we run it we get the following error

Server Time: Thu, 29 Aug 2019 11:02:58 +0100

Execute scheduled task: Sync cohort role assignments (tool_cohortroles\task\cohort_role_sync)

... started 11:02:58. Current memory use 18.7MB.
Sync cohort roles...

!!! Coding error detected, it must be fixed by a programmer: A lock was created but not released at:[dirroot]\lib\cronlib.php on line 99

 Code should look like:

 $factory = \core\lock\lock_config::get_lock_factory('type');
 $lock = $factory->get_lock(Resource id #602);
 $lock->release();  // Locks must ALWAYS be released like this.

!!!

!!

Error code: codingerror !!

!! Stack trace: * line 117 of \lib\classes\lock\lock.php: coding_exception thrown
* line 114 of \lib\cronlib.php: call to core\lock\lock->__destruct()
* line 73 of \lib\cronlib.php: call to cron_run_scheduled_tasks()
* line 61 of \admin\cli\cron.php: call to cron_run()
 !!

I am pretty new to PHP and Servers and whatnot but i have no idea what this is or how to solve it


Moodle Version 3.7.1
Server: Windows Server 2012 R2
PHP Version: 7.3.8
DB: MySQL 5.7.13

Please can somebody help. 

Regards
Stuart Smith

Average of ratings: -
In reply to Stuart Smith

Re: CRON lock Error

by Stuart Smith -
I have now deleted the lock folder but am still getting the same error message.
Any idea?
Anyone?
In reply to Stuart Smith

Re: CRON lock Error

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That's a generic error that you'll see if Moodle can't get a lock. It isn't terribly specific or helpful.

Can we back up? What exactly were you doing when you got this error and what was going wrong that led you to check?

You get this error if, e.g., cron is already running "normally" and you then try run it from the command line. You can also get it if there is some other problem in a scheduled (or adhoc) task. This would point to a broken plugin of some description.

You might also want to check your Scheduled task log (site administration > Server > Scheduled task log)
In reply to Howard Miller

Re: CRON lock Error

by Stuart Smith -
\tool_cohortroles\task\cohort_role_sync
As Ken said it is to do with this I disabled it in the scheduler and CRON is running again now
In reply to Stuart Smith

Re: CRON lock Error

by Ken Task -
Picture of Particularly helpful Moodlers

Well that's good ... but are you using cohorts?  IF not, great!  If you are, shouldn't sync be on?

'SoS', Ken

In reply to Ken Task

Re: CRON lock Error

by Stuart Smith -
No we are not using Cohorts.
However i have turned it back on again now and everything is working as it should be.
So its the classic IT solution of turn it off and back on again.
In reply to Stuart Smith

Re: CRON lock Error

by Ken Task -
Picture of Particularly helpful Moodlers

Glad to hear it.  You might have discovered the fix for some of such errors ...but man oh man ... that reminds me too much of NT 4.0 days ... when all else fails ... reboot! :\   Don't wanna re-live those days! :|

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: CRON lock Error

by James Kinsman -
I found my answer was in mdl_lock where I could set NULL to get rid of the lock.
In reply to James Kinsman

Re: CRON lock Error

by Shari Sa -

I have this problem too and I didn't understand what did you do. Thank you to explain for me more. Where is the  mdl_lock?