cron fails to run: !!! Error reading from database !!!

cron fails to run: !!! Error reading from database !!!

by hugo joe -
Number of replies: 8

Moodle 2.6.2 upgraded from moodle 2.6.1 in Debian 7 (nginx+mysql) works well except cron.

My cron.php fails to run both in cli and web. Screen shows:

.............
Finished workshop allocation methods ... used 6 dbqueries ... used 0.013134002685547 seconds done. Processing module function assign_cron ...... started 15:14:14. Current memory use 6.9MB. !!! Error reading from database !!!

 Best Regards.

Hugo

Average of ratings: -
In reply to hugo joe

Re: cron fails to run: !!! Error reading from database !!!

by Pawel Wojnicki -

Hi,

Any luck with this? I'm fighting with the same issue.


In reply to hugo joe

Re: cron fails to run: !!! Error reading from database !!!

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Switch on Debugging (right up to Developer level) and do it again. 

In reply to Howard Miller

Re: cron fails to run: !!! Error reading from database !!!

by Pawel Wojnicki -

It says I have an illegal mix of collations, but my sql dump file doesn't have a utf_general_ci collation, everything is in unicode.


Server Time: Wed, 19 Nov 2014 11:55:40 +0100


 Created missing context instances
Cleaned up stale user sessions
Running auth crons if required...
... started 11:55:40. Current memory use 25.1MB.
Running cron for auth/mnet...
Running enrol crons if required...
Starting activity modules
Processing module function turnitintool_cron ...... started 11:55:40. Current memory use 28.9MB.
... used 0 dbqueries
... used 4.9114227294922E-5 seconds
done.
Processing module function assign_cron ...... started 11:55:40. Current memory use 29.1MB.
!!! Error reading from database !!!
!! Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
SELECT g.id as gradeid, a.course, a.name, a.blindmarking, a.revealidentities,
                       g.*, g.timemodified as lastmodified
                 FROM mdl_assign a
                 JOIN mdl_assign_grades g ON g.assignment = a.id
            LEFT JOIN mdl_assign_user_flags uf ON uf.assignment = a.id AND uf.userid = g.userid
                 JOIN mdl_course_modules cm ON cm.course = a.course
                 JOIN mdl_modules md ON md.id = cm.module
                 JOIN mdl_grade_items gri ON gri.iteminstance = a.id AND gri.courseid = a.course AND gri.itemmodule = md.name
                 WHERE g.timemodified >= ? AND
                       g.timemodified <= ? AND
                       uf.mailed = 0 AND gri.hidden = 0
[array (
  0 => 1416308140,
  1 => 1416394540,
)]
Error code: dmlreadexception !!
!! Stack trace: * line 425 of /lib/dml/moodle_database.php: dml_read_exception thrown
* line 1005 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
* line 1533 of /mod/assign/locallib.php: call to mysqli_native_moodle_database->get_records_sql()
* line 859 of /mod/assign/lib.php: call to assign::cron()
* line 269 of /lib/cronlib.php: call to assign_cron()
* line 88 of /admin/cron.php: call to cron_run()
 !!
In reply to Pawel Wojnicki

Re: cron fails to run: !!! Error reading from database !!!

by Rob Johnson -

Do you have access to something like phpmyadmin?  Take a look at each table to be sure your collations are the same for every table, and even within tables.    I have seen databases that are set to one character set, but have mixed tables.

In reply to Pawel Wojnicki

Re: cron fails to run: !!! Error reading from database !!!

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is a really weird part of mysql. The default collation depends on locale settings and such. What it doesn't do is cascade down from the parent structure in the database as one might expect. There's lots of discussion around about this (Google) and some scripts you can run to fix it up.

Be careful not to confuse the collation with the character set - they are entirely different things.

Average of ratings: Useful (1)
In reply to Howard Miller

Re: cron fails to run: !!! Error reading from database !!!

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Why not just use admin/cli/mysql_collation.php CLI script to fix the database?
Average of ratings: Useful (2)
In reply to Petr Skoda

Re: cron fails to run: !!! Error reading from database !!!

by Pawel Wojnicki -

Thanks Petr, this script did the job for me smile

In reply to Petr Skoda

Re: cron fails to run: !!! Error reading from database !!!

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

...I would had I remembered it existed smile