Hello everyone!
I recently came to be the admin of an existing Moodle installation. While checking the site handed to me, I noticed that cron hadn't run in a *very* long time. The site has been updated twice(!) while cron was not running, too.
I added cron to the crontab on the server and let it run manually in a console. It took about a minute to finish everything and send out emails.
At first, I thought everything was fine, but soon I noticed that Moodle would display a database error whenever cron had been run recently. Then it would take about a minute for Moodle to spring back to life without any intervention.
In case of admin/index.php?cache=0, the he error shown would be this:
SELECT * FROM mdl_context WHERE contextlevel = ?
[array (
0 => 10,
)]
Error code: dmlreadexception
- line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
- line 1273 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
- line 1671 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
- line 1643 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
- line 1622 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
- line 6308 of /lib/accesslib.php: call to moodle_database->get_record()
- line 758 of /lib/setup.php: call to context_system::instance()
- line 27 of /config.php: call to require_once()
- line 88 of /admin/index.php: call to require()
I also got the following error, when I change the cache parameter from 1 to 0:
Afterwards, the cron job would often print an error message regarding the database, also executing this query:
SELECT * FROM mdl_context WHERE contextlevel = ?
[array (
0 => 10,
)]
What could cause such misery? Is the database corrupted due to the cron not running for so long or could it be something else?
We are using Moodle 3.10.3+ (Build: 20210430) with MariaDB.