Escalated from OU Bug 3791, 'Live cron exhausts memory, before "core" jobs including sync_metacourses'
Cron is consistently failing on
"Removing expired enrolments ...Allowed memory size of 134217728 bytes exhausted..."
The attached patch uses the preferred 'rs_fetch_next_record' call, and only gets required fields, to reduce memory use.
It removes the 'course' table, enrolperiod>0 check and loop, introduced for Bug
MDL-10181 (also
MDL-8785) - is this really necessary? If so this SQL join could form the basis.
SELECT ra.roleid, ra.userid, ra.contextid
FROM mdl_course c
INNER JOIN mdl_context cx ON cx.instanceid = c.id
INNER JOIN mdl_role_assignments ra ON ra.contextid = cx.id
WHERE cx.contextlevel = '50'
AND timeend > 0
AND timeend < 1189123200;
--AND c.enrolperiod > 0;