-
Notifications
You must be signed in to change notification settings - Fork 147
Description
Subject: Performance Bottleneck in local_o365 Upgrade Script (v5.0.1 2025040805) on Large Sites
Description:
We’ve come across a critical performance issue during the upgrade of the local_o365 plugin to version 5.0.1 (2025040805) from 4.5.2 (2024100710) on a large-scale Moodle site. The upgrade script includes a database cleanup step in upgrade.php that causes excessive downtime currently exceeding 72 hours
Environment: Moodle 4.5.7 to 5.0.3
component: local_o365
Version: 4.5.2 (2024100710) to 5.0.1 (2025040805)
Affected table: logstore_standard_log
Issue Details:
The upgrade script in /local/o365/db/upgrade.php (line 1307 onward) attempts to delete log entries using a subselect query:
if ($oldversion < 2024100711) {
// Delete config log entries created by mistake.
$confignames = ['apptokens', 'teamscacheupdated', 'calsyncinlastrun', 'task_usersync_lastdeltatoken',
'task_usersync_lastdelete', 'cal_site_lastsync', 'cal_course_lastsync', 'cal_user_lastsync'];
foreach ($confignames as $configname) {
// Delete logstore_standard_log records.
$DB->delete_records_select('logstore_standard_log',
'eventname = :eventname AND objectid IN (SELECT id FROM {config_log} WHERE plugin = :plugin AND name = :name)',
['eventname' => '\core\event\config_log_created', 'plugin' => 'local_o365', 'name' => $configname]);
// Delete config_log records.
$DB->delete_records('config_log', ['plugin' => 'local_o365', 'name' => $configname]);
}
// O365 savepoint reached.
upgrade_plugin_savepoint(true, 2024100711, 'local', 'o365');
}
This query performs poorly on large datasets due to the subselect against mdl_logstore_standard_log.
Please review and consider optimising this upgrade step in the next release. I am happy to provide any further details.