Upgrading to 4.1.0 gives me this cron error!

Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -
Number of replies: 31
Hi to everyone,
I just upgraded (two times, the first time I thought I made some mistakes while upgrading, but same on the second time after restoration). 

When I try to run the cron manually from Plesk (ubuntu) it gives me this error:

Task "/var/www/vhosts/site.com/httpdocs/elearn/admin/cli/cron.php" completed with error in 1 seconds, output:

Server Time: Tue, 29 Nov 2022 00:04:54 +0100


!!! Exception - Call to a member function get_concurrency_limit() on bool !!!



PHP version is on 7.4.33 for both site and cron.


Any ideas what should I do to fix this?


Average of ratings: -
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Ken Task -
Picture of Particularly helpful Moodlers

Did you use Softaculous?  or one of those infamous 1 button click installs/upgrades?

By chance did you check environment in moodle and update the component prior to pulling trigger on upgrade to see if everything green there?

Don't think Plesk (your panel) has a 'run a script' tool so you must talking about the setup of the cron job.   Got command line?   If so:

cd /path/to/moodlecode/admin/cli/

php -v (to show what version of PHP would be found using command line ... which is the same path to php-cli  as one would enter into the cron job setup for moodle in the Plesk Cron Jobs setup panel.

If that is OK, then:

php cron.php

Plesk panels do have ability to choose a PHP version for a site/domain.   What is the PHP version for your site?

'SoS', Ken


In reply to Ken Task

Re: Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -
Dear Ken thank you for your reply. No it isn't an one click install/update but I did that all manually.
Please see this below.
php version

plesk

This isn't happening with the previous version of moodle but only on Moodle v4.1.0.
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Ken Task -
Picture of Particularly helpful Moodlers

The Plesk GUI setup does have a check box for 'run a php script' and a run now test ... but what version of PHP is that running?

You have command line ... obviously ... you show php version 7.4.33 (cli).

So ... let's see:

Issue:

cd /path/to/moodle41code/admin/cli/

Then

which php

That should show a path ... like /usr/bin/php or similar

Now run the cron job using that full path to php(cli) executable.

/full/path/to/phpcli/executable/php ./cron.php

Yes, cron job worked before .... not doubting you ... how could I?  I don't host where you host ... I don't use Plesk .. just trying to help you out! smile

What addons (plugins) do you have?   Could you are tech support where you host install 'moosh'?   If so ...

In 4.1 moodlecode, an addons.txt file

looks like:

 cat addons.txt
mod_certificate
mod_checklist
mod_questionnaire
block_checklist
availability_mobileapp
format_grid
format_onetopic
format_topcoll
report_coursesize
report_coursestats
report_customsql
gradeexport_checklist
local_mass_enroll
local_mobile
tinymce_tiny_mce_wiris
atto_wiris
filter_wiris

Then an executable bash shell script called 'checkaddons' that looks like:

#!/bin/bash
#
cd /var/www/html/;
echo 'Add-on listing: ';
cat ./addons.txt;
echo '---------------------';
for i in `cat ./addons.txt`
do
   echo "Addon in que: $i";
moosh -n plugin-list |grep $i
done

Incompatible plugins can do strange things to cron!

'SoS', Ken


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

Re: Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -

I think I got a more serious problem than I thought... I have a VPS so I have no idea what is wrong...

Moreover, I see this is a problem with MySQL but I use MariaDB. 

Thank you Ken for your support! You really helped me identify this error.

moodle

Average of ratings: Useful (1)
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Enable debugging, this should show more detail with the error.

Which Moodle version did you upgrade from?

When you restored the database did you delete all the tables first? If you're using MySQL/MariaDB then a restore doesn't delete any newly created tables. This can cause problems with upgrades because the new 4.1.0 tables are already present before the upgrade starts.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -
I did all of that, yet the problem persists however, the debugging message is this:

Default exception handler: Exception - Call to a member function get_concurrency_limit() on bool Debug:
Error code: generalexceptionmessage
* line 674 of /lib/classes/task/manager.php: Error thrown
* line ? of unknownfile: call to core\task\manager::core\task\{closure}()
* line 673 of /lib/classes/task/manager.php: call to array_map()
* line 184 of /lib/cronlib.php: call to core\task\manager::get_next_adhoc_task()
* line 76 of /lib/cronlib.php: call to cron_run_adhoc_tasks()
* line 178 of /admin/cli/cron.php: call to cron_run()
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -
Just noticed that when I disable 'Ad hoc task concurrency limit' (putting it a 0) then the cron runs successfully. But when I enable put the default value (3) to Ad hoc task concurrency limit, then crons doesn't run.
Average of ratings: Useful (1)
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Try purging caches just in case.

Are you getting the message Failed to load task: … anywhere?

Can you tell us what's in database table mdl_task_adhoc when the error occurs? The  output from SQL query:

SELECT * FROM mdl_task_adhoc;
Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -
Dear Leon, thank you for your reply. I'm getting this:
/admin/cli/cron.php" completed with error in 1 seconds, output:

Server Time: Tue, 29 Nov 2022 21:55:52 +0100


!!! Exception - Call to a member function get_concurrency_limit() on bool !!!


Default exception handler: Exception - Call to a member function get_concurrency_limit() on bool Debug:
Error code: generalexceptionmessage
* line 674 of /lib/classes/task/manager.php: Error thrown
* line ? of unknownfile: call to core\task\manager::core\task\{closure}()
* line 673 of /lib/classes/task/manager.php: call to array_map()
* line 184 of /lib/cronlib.php: cal...

And on the table you mentioned is this:
db
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -
Thank you Leon and Ken, the solution was this:

Deleting these three rows from  mdl_task_adhoc table on database:
9 local mootivated
Nocal motivated\taskladhoc role_sync
10 local_mootivated
Vocal mootivated\taskladhoc_role_sync
11 local motivated
Vocal motivated\taskladhoc queue users for push


The problem is solved and hopefully it will be helpful for anyone who faces the same!
Average of ratings: Useful (1)
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Ken Task -
Picture of Particularly helpful Moodlers

2nd column of that table is component.

The data you deleted shows a local component called motivated?

Do you have a local plugin called 'motivated'?

And just to be sure ... all addons (plugins) are compat with 4.1.0?

'SoS', Ken


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

Re: Upgrading to 4.1.0 gives me this cron error!

by Ardian Deari -
Yes Ken, correct, it was a plugin installed earlier but then deleted. No idea why these data remained there! The other plugins are now all up-to-date!
Thank you!
In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
HI I am bumping into the same issue.. After upgrade to 4.1.0 we get the error:  !!! Fehler: Call to a member function get_concurrency_limit() on bool !!! >

debugging on shows me the following error
++ Failed to load task: \mod_forum\task\refresh_forum_post_counts ++
* line 324 of /lib/classes/task/manager.php: call to debugging()
* line ? of unknownfile: call to core\task\manager::adhoc_task_from_record()
* line 661 of /lib/classes/task/manager.php: call to array_map()
* line 184 of /lib/cronlib.php: call to core\task\manager::get_next_adhoc_task()
* line 76 of /lib/cronlib.php: call to cron_run_adhoc_tasks()
* line 81 of /admin/cron.php: call to cron_run()
!!! Fehler: Call to a member function get_concurrency_limit() on bool !!!
!! 
Error code: generalexceptionmessage !!
!! Stack trace: * line 674 of /lib/classes/task/manager.php: Error thrown
* line ? of unknownfile: call to core\task\manager::core\task\{closure}()
* line 673 of /lib/classes/task/manager.php: call to array_map()
* line 184 of /lib/cronlib.php: call to core\task\manager::get_next_adhoc_task()
* line 76 of /lib/cronlib.php: call to cron_run_adhoc_tasks()
* line 81 of /admin/cron.php: call to cron_run()
 !!
When I go to the mdl_task_adhoc I see what is below. 

since it not completely the same I am little bit usure what to do: create a tracker or .... ? 

Any advice would be appriciated.
attachment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MjcwMjE2MzM0MDksImRvbWFpbiI6Imx0bmMuZnJlc2hzZXJ2aWNlLmNvbSIsInR5cGUiOjF9.X0XwjzQ0siQzy3fN_KHQsZYWn1-zd5GNbs4WZNpEfWM
In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Had a look at this and found that MDL-71747 removed the file '/mod/forum/classes/task/refresh_forum_post_counts.php', which contains the class stipulated in the 'task_adhoc' table, i.e. 'class refresh_forum_post_counts extends \core\task\adhoc_task' as in that location in M4.0, i.e. this information in M4.1:

function upgrade_stale_php_files_present(): bool {
    global $CFG;
    $someexamplesofremovedfiles = [
        // Removed in 4.1.
        '/mod/forum/classes/task/refresh_forum_post_counts.php',
        '/user/amd/build/participantsfilter.min.js',
        '/user/amd/src/participantsfilter.js',
        // Removed in 4.0.

in 'lib/upgradelib.php'.  Therefore for whatever reason, I don't know, that task wasn't checked to be removed from the DB.  And so as an educated guess, its safe to remove that entry in the DB.  There probably does need to be a tracker issue for this if not already.

G

Attachment blob1673543836111.png
In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Ken Task -
Picture of Particularly helpful Moodlers

+1 to what Garth has said ...

In a 4.1+ (Build: 20221201) that task does not exist.

Maybe updating to highest 4.1 available will fix! smile

'SoS', Ken


In reply to Ken Task

Re: Upgrading to 4.1.0 gives me this cron error!

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I'm currently running '4.1+ (Build: 20230105)', Ken.  And that's the code I did my research on, so no fix in that!

In reply to Gareth J Barnard

Re: Upgrading to 4.1.0 gives me this cron error!

by Ken Task -
Picture of Particularly helpful Moodlers

Just updated to latest 4.1 ...

mysql> select * from mdl_task_adhoc where classname like '%counts';
Empty set (0.01 sec)

Gone!

My sandbox 4.1 site was upgraded from a 3.10.highest.

If OP's server not the highest 4.1, probably a good idea to update it anyway! smile

'SoS', Ken


In reply to Ken Task

Re: Upgrading to 4.1.0 gives me this cron error!

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
i did the latest update - did not fix the issue. Removing the line did fix the issue. I could not find a tracker related to this issue yesterday but will take another look
In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I think we had this issue because of the 'process' we where doing and might not cause for all Moodle sites an issue while upgrade. Therefor decided to not create a tracker. But for those who stumble on this issue.
This was our 'setup'

* cron was turned off, due to migration to different hosting. We turned the cron on when we went live.
* We upgraded Moodle from 3.1 > 3.2 > 3.5 > 3.6 >3.9 > 4.1

i think that main problem was that the task was already in the dB table .
So this issue might not had been if we either ran the cron at 3.9 at least 1, and/or take an update step .
In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Benjamin Wright -

I recently encountered the same issue as Gemma. We upgraded a site from 3.6.1 to 3.9, and then to 4.1.2. After completing this, we found out that some cron processes were not completing. Our cron was dying prematurely, so only the tasks that processed earlier than "\core\task\fix_file_timestamps_task" actually completed. It would certainly be simpler if there was a check during the upgrade process to clean up this (or possibly any other such) erroneous core cron jobs after upgrading.

We also did not run the cron on any intermediate version (i.e. Moodle 3.9, in our case) and only ran the cron on 4.1.2. if the above cannot be implemented, is running the cron with each intermediate version during a multi-version upgrade the way to prevent this sort of issue?

Let me know if there is anything I'm missing, or if I can provide any further information.

In reply to Benjamin Wright

Re: Upgrading to 4.1.0 gives me this cron error!

by Zeca Boy -
Hi people,

I have a same problem with my cron.php, and i remove the line with value (mod_forum) on table mdl_task_adhoc on Moodle DB, works very well.



# php admin/cli/cron.php
Server Time: Fri, 15 Sep 2023 11:41:21 +0100

Ran 0 adhoc tasks found at Fri, 15 Sep 2023 11:41:21 +0100
Cron script completed correctly
Cron completed at 11:41:21. Memory used 4.9Â MB.
Execution took 0.126993 seconds

Regards
In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Tim Hoorelbek -
Hi Gemma, Could you please clarify? Removing what line fixed the issue?
In reply to Tim Hoorelbek

Re: Upgrading to 4.1.0 gives me this cron error!

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hi Tim

you go to the database, search for the table  mdl_task_adhoc

You will find there a 'row' (line) with in the column 'classname': 
mod/forum/classes/task/refresh_forum_post_counts.php

Removing that entry from the table willl ensure that you cron error will disappear. 


In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Eric Albert -
HI Gemma,

Looking at that table we do not have that row in the classname field in mdl_task_adhoc. We're not exactly clear on how to determine what row is creating the issue. I've uploaded the entire table results. I appreciate your assistance so much!
In reply to Eric Albert

Re: Upgrading to 4.1.0 gives me this cron error!

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
hmm to be sure it's the same issue, can you share the debugging information when you run the cron, because that will show more clear which task is failing. 


In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Eric Albert -
Just wanted to follow up and see if there were any thoughts on the log or if there was anything else we could look at. We're pretty lost right now on next steps. Thank you!
In reply to Eric Albert

Re: Upgrading to 4.1.0 gives me this cron error!

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hi Eric,

sorry missed the forum message I guess - it's a little bit busy. .

Okay it's the same notification , except it clear stated for me that it had to do witht he forum. I am not sure which rows to remove to help your case. 

Ken is far better in this then me smile 

i am not sure how much damage it would do if you would rmeove the tasks until , maybe make a backup before you try it out? 

For me it was the mod_forum, but for Ardian that started this treat it was something else. The one thing we have in common it seems that during the upgrade the cron died to earlier and left task in the table that where not being cleaned up 

I am sorry that I cannot really help you solve this puzzle. 

Gem


In reply to Gemma Lesterhuis

Re: Upgrading to 4.1.0 gives me this cron error!

by Ken Task -
Picture of Particularly helpful Moodlers
Is there an epoch time stamp column for next run?
Is that epoch time now past?
If you remove a row, that task is no longer in the hopper so to speak and thus won't be called - it's gone!   Whatever is creating those will make another entry for sure if it's needed.

'SoS', Ken

In reply to Ardian Deari

Re: Upgrading to 4.1.0 gives me this cron error!

by Ken Task -
Picture of Particularly helpful Moodlers
Don't run what you run ... so following is a guess ...

There is a concurrency limit of 3 on ad_hoc_task processing.
(spawns 3 processes all doing the same thing)

Errors look like 3 is not enough ... bump to 6 ... but do realize for each of those spawned processes memory is beng used ... in 30-50 MB range?   So if I am correct 3 more to 6 would require more memory to complete.   That subtracted from the free memory you have to handle other server processes and the users either logging on or doing something.

Think if I try 6, I'd be in terminal running top to see memory usage in realtime.
Could be that 6 too many ... ok, maybe 5 ... anyway, issue ... no one answer.
Think ya just gotta tinker with it some more and observe - then adjust - upwards at first and maybe back down a bump or two to see!

Sorry can't be more specific than that ... not capable of doing 'Vulcan Mind Melds' with remote servers! smile

'SoS', Ken

In reply to Ken Task

Re: Upgrading to 4.1.0 gives me this cron error!

by Eric Albert -
Ken and Gemma thank you both so much for you help on this! It put us on a path to resolution. Oddly enough, we had a pdf editing plugin that didn't have a 4.1 version, that we hadn't uninstalled that seemed to be holding up this process. Once we deleted that plugin and let the system run for several days it finally caught up without the need to delete any rows. I appreciate both of you!
Average of ratings: Useful (1)