So, we migrated our production server from Windows to Linux (RHEL 8).
Everything is working fine... except the cron, which was still on our Windows server since we were not ready to move it.
The database is on a totally different server and was untouched in the migration process.
The cron suddenly stopped working even since we installed
a new plugin (The cron was working fine on Windows after the Moodle Linux migration for a week after the transition !).
I did some research and found that PHP serialize could be causing problem while running the Cron from Windows and having Moodle on Linux, so we decided to run the cron task on the Linux server directly.
Now the cron task is filled with Error writing to database messages. It sent notifications and emails multiple times because of that.
I activated $CFG->showcrondebugging = true; and I don't see this error anymore, but instead my cron logs are filled with various errors such as:
... used 0,15621018409729 seconds Adhoc task complete: mod_forum\\task\\send_user_notifications ', )]) Debug info: Column count doesn't match value count at row 1 INSERT INTO mdl_task_log (type,component,classname,userid,timestart,timeend,dbreads,dbwrites,result,output) VALUES(?,?,?,?,?,?,?,?,?,?) [array ( 0 =>; 1, 1 => 'mod_forum', 2 =>; 'mod_forum\\task\\send_user_notifications', 3 => '18877', 4 => 1618416008.297498, 5 =>; 1618416008.456419, 6 => 30, 7 => 3, 8 => 0, 9 => 'Execute adhoc task: mod_forum\\task\\send_user_notifications
Even though it executes the tasks and can READ the database just fine, it seems like it's now struggling to write/update the cron task table and executes the tasks more than once. Those error writing to database are quite concerning and I had to deactivate the cron to prevent spamming my users.
Anyone has a clue or a track for me to follow to debug this out ?
The MySQL user didn't have any change to its permissions whatsoever and was working just fine before we installed the quizaccess_delayed plugin... but the fact that we had previously switched to Linux could also not help.
Also, everyone can access the website without issue, so the Database user and permissions aren't the issue here.
Windows1 - Moodle web
Windows2 - Database (unchanged)
Windows1 - Moodle Cron
Linux1 - Moodleweb
Windows2 - Database (unchanged)
Windows1 - Moodle Cron (not working, so we switched this to Linux1 with crontab and the errors mentioned above began appearing)
I also have to add - ever since we installed the plugin, the reason we moved the Cron away from Windows was that we began having this error when running the cron task:
Moodle upgrade pending, cron execution suspended.
This error is not happening on Linux, which is what lead me to thing that PHP Serialize was the issue, thus moving the Cron to Linux.
Any obvious thing we forgot ?
Edit: Can the server locale affect the Cron (decimals being comma instead of a full-stop, etc.) ?
Edit2: When I got take a look at the tasks logs manually, they seem to complete sucessfully... I don't understand why they ran multiple times (thus spamming the users with emails).
Here's the log from one of the runs on Linux this morning (see file attached). It doesn't show any errors despite what I was seeing in my cron output (directly calling php admin/cli/cron.php >> cron.log)