-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.4.8, 4.5.4, 5.0
-
MOODLE_404_STABLE, MOODLE_405_STABLE, MOODLE_500_STABLE
We have a client who is seeing this error from the analytics cleanup task:
Scheduled task failed: Analytics cleanup (core\task\analytics_cleanup_task),
|
Error writing to database (number of parameters must be between 0 and 65535
|
DELETE FROM mdl_analytics_used_analysables WHERE modelid = $1 AND analysableid IN (VALUES ($2::bigint),($3::bigint),...,($122650::bigint))
|
[array (
|
0 => '11',
|
...
|
122649 => 958948,
|
)])
|
]
|
Backtrace:
|
* line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
|
* line 358 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->read_slave_query_end()
|
* line 1457 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
|
* line 687 of /analytics/classes/manager.php: call to pgsql_native_moodle_database->delete_records_select()
|
* line 58 of /lib/classes/task/analytics_cleanup_task.php: call to core_analytics\manager::cleanup()
|
* line 410 of /lib/classes/cron.php: call to core\task\analytics_cleanup_task->execute()
|
* line 208 of /lib/classes/cron.php: call to core\cron::run_inner_scheduled_task()
|
* line 125 of /lib/classes/cron.php: call to core\cron::run_scheduled_tasks()
|
* line 186 of /admin/cli/cron.php: call to core\cron::run_main_process()
|
Tracking it down to \core_analytics\manager::cleanup(), the process builds large sets of ids to delete, but doesn't chunk them out into acceptable numbers of parameters for use in the IN statement.
A quick reading of the code implies to me that using IN is the correct way to do it, and it could not (at least easily) be refactored with sub-queries. So instead it needs to do chunk processing IMO.
They are a Aurora Postgres site which probably related. Interestingly \pgsql_native_moodle_database::get_in_or_equal() claims to deal with this, but it doesn't seem to actually work.