如何解决 Moodle 3.8.4 上的 ddl 执行错误?

问题描述

我使用 Moodle 3.8.4 与 Azure Database for MysqL 服务器相连。我正在尝试通过右键单击活动并选择“编辑”->“复制”来复制活动。

duplicate_activity_moodle

我已将调试模式设置为 DEVELOPER,然后我看到以下错误消息:

> UnkNown table 'learn_nprod.mdl_backup_ids_temp'
DROP TABLE mdl_backup_ids_temp
Error code: ddlexecuteerror
* line 492 of /lib/dml/moodle_database.PHP: ddl_change_structure_exception thrown
* line 1072 of /lib/dml/MysqLi_native_moodle_database.PHP: call to moodle_database->query_end()
* line 77 of /lib/ddl/database_manager.PHP: call to MysqLi_native_moodle_database->change_database_structure()
* line 332 of /lib/ddl/database_manager.PHP: call to database_manager->execute_sql_arr()
* line 171 of /backup/util/dbops/backup_controller_dbops.class.PHP: call to database_manager->drop_table()
* line 40 of /backup/moodle2/backup_stepslib.PHP: call to backup_controller_dbops::drop_backup_ids_temp_table()
* line 34 of /backup/util/plan/backup_execution_step.class.PHP: call to create_and_clean_temp_stuff->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 119 of /backup/util/plan/backup_plan.class.PHP: call to base_plan->execute()
* line 375 of /backup/controller/backup_controller.class.PHP: call to backup_plan->execute()
* line 3530 of /course/lib.PHP: call to backup_controller->execute_plan()
* line 3518 of /course/externallib.PHP: call to duplicate_module()
* line 250 of /lib/externallib.PHP: call to core_course_external::edit_module()
* line 79 of /lib/ajax/service.PHP: call to external_api::call_external_function()

另外,我发现备份作业被冻结到了 0%:

backup_job

在 Azure MysqL 上,我更改了以下值:

wait_timeout = 440,max_heap_table_size = 16777216,tmp_table_size = 16777216,innodb_strict_mode = ON

致:

wait_timeout = 3600,max_heap_table_size = 2147483648,tmp_table_size = 536870912,innodb_strict_mode = OFF

然后我重新启动了 Azure MysqL 服务器。此操作仅在几分钟内解决了我的问题。有什么建议可以绕过这个错误吗?
MysqL 设置位于此 link.

更新:我遵循了这个 solution,它实际上不使用临时表,但是我不明白为什么会发生这种情况,以及它是否会对数据库产生影响。

解决方法

我通过编辑以下文件解决了这个问题:./htdocs/lib/dml/mysqli_native_moodle_database.php 我改变了这一行:

curl multi-container-service-2.default.svc.cluster.local

为此:

$sql = "SHOW TABLES LIKE '$prefix%'";

似乎 Azure MySQL 服务器在 DROP 查询之前缓存了临时表。