-
Improvement
-
Resolution: Fixed
-
Minor
-
3.9.17
-
MOODLE_39_STABLE
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MDL-75907-master -
Recently, scheduled task \core\task\stats_cron_task was found running in a transaction with the following SQL statment not completing in a reasonable time:
INSERT INTO mdl_temp_stats_daily (stattype, timeend, courseid, roleid, stat1, stat2) SELECT 'activity', 1664460000 AS timeend, courseid, roleid, SUM(statsreads), SUM(statswrites) FROM (
SELECT pl.courseid, pl.roleid, sud.statsreads, sud.statswrites FROM mdl_temp_stats_user_daily sud, ( SELECT DISTINCT te.userid, te.roleid, te.courseid FROM mdl_temp_enroled te WHERE te.roleid <> 19 AND te.userid <> 1 ) pl WHERE sud.userid = pl.userid AND sud.courseid = pl.courseid AND sud.timeend = 1664460000 AND sud.stattype='activity' ) inline_view GROUP BY courseid, roleid HAVING SUM(statsreads) > 0 OR SUM(statswrites) > 0;
The transaction was held open for 4 days and this caused severe issues related to database performance.