首页 > 解决方案 > 当我尝试从外部数据库日志中提取时,Moodle 实时日志中的“dmlreadexception”错误是什么意思?以及任何修复建议?

问题描述

我正在尝试使用 Moodle 中的外部数据库日志插件将标准日志表复制到外部数据库中,以便更轻松地进行一些分析工作。

我激活了外部数据库日志并在设置页面上添加了所有正确的设置。我点击了“测试连接”,它连接成功并成功返回了表格列标题。但是,如果我单击并创建一些日志,它们在标准日志存储中可见,但我的外部数据库表仍然是空的。

因此,我尝试使用与我在外部数据库日志存储设置中放入的相同凭据在 TablePlus 中本地连接到我的外部数据库,并且我可以成功连接和写入。

接下来我进入实时日志并选择标准日志,它们显示得很好。然后我点击了外部数据库日志(除了 2 行手动输入的数据,里面什么都没有),得到了这个错误:

URL: https://ohsu.mrooms3.net/
Debug info: ERROR: syntax error at or near "{" LINE 1: SELECT COUNT('x') FROM {OpenLMSLog} WHERE courseid = $1 AND ... ^ SELECT COUNT('x') FROM {OpenLMSLog} WHERE courseid = $1 AND timecreated > $2 AND anonymous = $3 [array ( 0 => '1', 1 => 1604556625, 2 => 0, )] Error code: dmlreadexception
Stack trace:
 * line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
 * line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
 * line 920 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
 * line 1624 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
 * line 1697 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
 * line 1912 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
 * line 1895 of /lib/dml/moodle_database.php: call to moodle_database->count_records_sql()
 * line 262 of /admin/tool/log/store/database/classes/log/store.php: call to moodle_database->count_records_select()
 * line 329 of /report/loglive/classes/table_log.php: call to logstore_database\log\store->get_events_select_count()
 * line 48 of /report/loglive/classes/table_log_ajax.php: call to report_loglive_table_log->query_db()
 * line 59 of /report/loglive/classes/renderer_ajax.php: call to report_loglive_table_log_ajax->out()
 * line 462 of /lib/outputrenderers.php: call to report_loglive_renderer_ajax->render_report_loglive()
 * line 53 of /report/loglive/loglive_ajax.php: call to plugin_renderer_base->render()

这是我在开发人员设置中打开调试后收到的唯一错误消息。我的目标是成功配置外部数据库来跟踪日志,但由于在测试连接时缺少错误消息,因此很难调试。

环境配置:打开LMS 3.8 MP2 (Build: 20201008) 外部db是postgres db所以我们在postgres驱动上设置。

标签: moodle

解决方案


尽管在外部数据库日志存储插件设置中使用了 Postgres 驱动程序,但外部数据库日志存储插件使用的 SQL 似乎与 Postgres 不兼容,如问题中显示的 SQL 中的“{”错误所示。有关文档,请参见此处。

为了解决这个问题,我们使用 MariaDB 而不是 Postgres,我们最终让外部数据库日志存储正常工作。

另请注意,您必须将列和数据类型与 Moodle db 中的模式完全匹配,然后您必须将 db 表的 ID 列设置为自动递增。如果您不知道架构是什么样的,“报告”下有一个 Admin SQL 界面,可让您运行 SQL。在侧面,有一个按钮可以查看数据库中任何表的架构。


推荐阅读