Cron problem: Scheduled task failed

Cron problem: Scheduled task failed

by Milan Ivetic -
Number of replies: 2

Cron is set to run on every minute (moodle 3.11.1). Cron worked five days ok. It suddenly stopped working, that is, it shows an error that it cannot connect to the database. Can anyone help. 

After running cron I get a page with the text:

Execute scheduled task: Site registration (core\task\registration_cron_task)
... started 23:45:29. Current memory use 4.4MB.
Site registration updated
... used 24 dbqueries
... used 1.4075291156769 seconds
Scheduled task complete: Site registration (core\task\registration_cron_task)
... used 25 dbqueries
... used 1.6099650859833 seconds
Scheduled task failed: Site registration (core\task\registration_cron_task),Error writing to database
Debug info:
MySQL server has gone away
INSERT INTO mdlve_task_log (type,component,classname,userid,timestart,timeend,dbreads,dbwrites,result,output,hostname,pid) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
[array (
  0 => 0,
  1 => 'moodle',
  2 => 'core\\task\\registration_cron_task',
  3 => 0,
  4 => 1629582329.2856369,
  5 => 1629582330.6965151,
  6 => 23,
  7 => 1,
  8 => 0,
  9 => 'Execute scheduled task: Site registration (core\\task\\registration_cron_task)
... started 23:45:29. Current memory use 4.4MB.
Site registration updated
... used 24 dbqueries
... used 1.4075291156769 seconds
Scheduled task complete: Site registration (core\\task\\registration_cron_task)
',
  10 => 'cp33.cpanelhosting.rs',
  11 => 8971,
)]
Backtrace:
* line 1357 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
* line 1403 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
* line 86 of /lib/classes/task/database_logger.php: call to mysqli_native_moodle_database->insert_record()
* line 306 of /lib/classes/task/logmanager.php: call to core\task\database_logger::store_log_for_task()
* line 949 of /lib/classes/task/manager.php: call to core\task\logmanager::finalise_log()
* line 262 of /lib/cronlib.php: call to core\task\manager::scheduled_task_complete()
* line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
* line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
* line 81 of /admin/cron.php: call to cron_run()

!!! Error reading from database !!!

Debug info: MySQL server has gone away
SELECT RELEASE_LOCK(?) AS unlocked
[array (
  0 => 'b8c2aee5784406f61da4e535738d7e3b34391d59',
)]
Error code: dmlreadexception
Stack trace: * 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 161 of /lib/classes/lock/mysql_lock_factory.php: call to moodle_database->get_record_sql()
* line 107 of /lib/classes/lock/lock.php: call to core\lock\mysql_lock_factory->release_lock()
* line 130 of /lib/cronlib.php: call to core\lock\lock->release()
* line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
* line 81 of /admin/cron.php: call to cron_run()

Average of ratings: -
In reply to Milan Ivetic

Re: Cron problem: Scheduled task failed

by Ken Task -
Picture of Particularly helpful Moodlers

What is in your config.php for wwwroot ... the url to your site?  Is the fully qualified domain name for your moodle in DNS?

The host shown in the scheduled task registering your site flips to a https://myhosting.sbb.rs/lp/c/ site and informs that hosting account is not available + says:

In case you are the owner of this hosting account, contact us for more information.

'SoS', Ken

In reply to Milan Ivetic

Re: Cron problem: Scheduled task failed

by Ken Task -
Picture of Particularly helpful Moodlers

The other clue is this one:

"MySQL server has gone away"

So from mysql client what does the following query as superuser show:

mysql> show variables like 'max_allowed%';

max_allowed_packet should be set higher.
or if using version 8 of MySQL:

Default is 16M ... 32M ought to fix that.

'SoS', Ken