MySQL server has gone away when trying to delete course

MySQL server has gone away when trying to delete course

написао/ла Mateusz Szuter -
Број одговора: 7

Hello!

I've got error reading database when trying to delete course.

Here's the debug:

Debug info: MySQL server has gone away
SELECT count(r.repositoryid)
FROM mdl_files f
LEFT JOIN mdl_files_reference r
ON r.id = f.referencefileid
JOIN mdl_backup_ids_temp bi
ON f.id = bi.itemid
WHERE bi.backupid = ?
AND bi.itemname = 'filefinal'
[array (
0 => '0d907b30492199dd25dd7fd3de20d733',
)]
Error code: dmlreadexception
×Stack trace:
  • line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1175 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1558 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1631 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1841 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 522 of /backup/util/dbops/backup_controller_dbops.class.php: call to moodle_database->count_records_sql()
  • line 1997 of /backup/moodle2/backup_stepslib.php: call to backup_controller_dbops::backup_includes_file_references()
  • line 34 of /backup/util/plan/backup_execution_step.class.php: call to backup_store_backup_file->define_execution()
  • line 181 of /backup/util/plan/base_task.class.php: call to backup_execution_step->execute()
  • line 178 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
  • line 120 of /backup/util/plan/backup_plan.class.php: call to base_plan->execute()
  • line 322 of /backup/controller/backup_controller.class.php: call to backup_plan->execute()
  • line 121 of /admin/tool/recyclebin/classes/category_bin.php: call to backup_controller->execute_plan()
  • line 185 of /admin/tool/recyclebin/lib.php: call to tool_recyclebin\category_bin->store_item()
  • line 4823 of /lib/moodlelib.php: call to tool_recyclebin_pre_course_delete()
  • line 67 of /course/delete.php: call to delete_course()
Furthermorde, at 5:00 am I've got report from my cron with error reading database. 

I have max_allowed_packet = 2048M and max_execution_time = 600. Also tried to modify mysqli_native_moodle_database and changing @@default_storage to @@storage. Nothing helps тужан


У одговору на Mateusz Szuter

Re: MySQL server has gone away when trying to delete course

написао/ла Emma Richardson -
Слика Documentation writers Слика Particularly helpful Moodlers Слика Plugin developers

Does your database user have full access to the database?  

У одговору на Mateusz Szuter

Re: MySQL server has gone away when trying to delete course

написао/ла Ken Task -
Слика Particularly helpful Moodlers

Think that's the first time I've seen gone away on deleting a course!   Strange.

However, noticed the files humanly recognizable name has no filename extension ... but it does have a content hash ... 0d907b30492199dd25dd7fd3de20d733

Here's a suggestion ...

cd moodledata/filedir/

is there a 0d/90/ directory?

IF so create a file by the content hash name at that location:

cd 0d/90/

touch 0d907b30492199dd25dd7fd3de20d733

That last command creates a 0 byte file ... has nothing in it ... just the filename moodle is looking to remove and can't for some reason.

Make sure the touched file belongs to apache user/group.

Then try  to delete the course again with debugging still turned on ... you might find other strange things! :\

'spirit of sharing', Ken

У одговору на Ken Task

Odp: Re: MySQL server has gone away when trying to delete course

написао/ла Mateusz Szuter -

Hello Ken, thank for you answer. The folder '90' did not exist, I've created it and also a file inside it. Now I have a little different error:


Debug info: MySQL server has gone away
SELECT COUNT(*)
FROM mdl_backup_ids_temp b
JOIN mdl_user u ON u.id = b.itemid
WHERE b.backupid = ?
AND b.itemname = 'userfinal'
AND u.mnethostid != ?
[array (
0 => 'f6e03156c5a0c35dbdd6964ef70fbcb1',
1 => '1',
)]
Error code: dmlreadexception
×Stack trace:
  • line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1175 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1558 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1631 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1841 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 477 of /backup/util/dbops/backup_controller_dbops.class.php: call to moodle_database->count_records_sql()
  • line 1787 of /backup/moodle2/backup_stepslib.php: call to backup_controller_dbops::backup_includes_mnet_remote_users()
  • line 88 of /backup/util/plan/backup_structure_step.class.php: call to backup_main_structure_step->define_structure()
  • line 181 of /backup/util/plan/base_task.class.php: call to backup_structure_step->execute()
  • line 178 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
  • line 120 of /backup/util/plan/backup_plan.class.php: call to base_plan->execute()
  • line 322 of /backup/controller/backup_controller.class.php: call to backup_plan->execute()
  • line 121 of /admin/tool/recyclebin/classes/category_bin.php: call to backup_controller->execute_plan()
  • line 185 of /admin/tool/recyclebin/lib.php: call to tool_recyclebin\category_bin->store_item()
  • line 4823 of /lib/moodlelib.php: call to tool_recyclebin_pre_course_delete()
  • line 67 of /course/delete.php: call to delete_course()
And also, maybe that will help you a little more, here's my cron errors:

https://pastebin.com/eLCTjDsy

These happens like once a day at 5am, however today I got 4 errors since the morning. тужан

PS My moodledata group/owner is admin, not apache. However I have everywhere 777 cause it's not shared server. 

У одговору на Ken Task

Odp: Re: MySQL server has gone away when trying to delete course

написао/ла Mateusz Szuter -

Ken, one more time смешак

I've deleted all the content in the course and I could delete it. I've created new course, populated it and once again - I could delete it. Could have course been corrupted?

But still, maybe you will find something strange inside the cron errors? смешак Or maybe there were connected with that one course?

Have a nice day!

У одговору на Mateusz Szuter

Re: Odp: Re: MySQL server has gone away when trying to delete course

написао/ла Ken Task -
Слика Particularly helpful Moodlers

You might have been close to fixing by faking Moodle out with a
blank file named such that it could find the file.
That's a guess as the 'name' was 'userfinal'.   Those sorts of things
one normally sees the very end of a course.
So of those two were in the same section of the course, one might have
been able to remove only the activities in the section.
We'll never know now, since you've deleted each item in the course and then
the course.

Past bin shows MySQL server has gone away error as well.   When you increased max_packets_allowed you did restart the MySQL service, right?

What does a query like:

mysql> show variables like 'max%';

show?

Language - update to language packs.
which could have a cascading affect on other cron jobs.

Then warnings ... not errors ... but certainly not executing cleanly ...
var_export and in the trace shows logstore_standard table.

Think I'd attempt an update to the language packs.
Site Admin Menu -> Language -> Language Packs
Update all installed language packs.

Let's see what that does.

The other table ... log_store_standard ... is one of the larger tables.
Check settings in
Plugins -> Logging -> Manage log stores
Do you also have 'Legacy log' active?
Check Settings of the Standard Log ... 'keep logs for' ... set to never delete logs?

'spirit of sharing', Ken

У одговору на Ken Task

Odp: Re: Odp: Re: MySQL server has gone away when trying to delete course

написао/ла Mateusz Szuter -

Max variables from phpmyadmin:

MaxVariables

If I click update language packs, moodle says - every is up to date.

Legacy logs are turned off.

Yes, they are set to "never delete logs" смешак

Edit:
https://pastebin.com/p8CN0N0V - also, pastebin of error, when I tried to edit existing scorm package. Thrown once, second time was okey. Seems like really some problem with connection with database?