Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.8, 1.9
-
Component/s: Database SQL/XMLDB
-
Labels:None
-
Environment:The following SQL on the OU's live system returned count = 176574,
SELECT COUNT(*) FROM mdl_role_assignments WHERE timeend > 0 AND timeend < 1189123200;
-
Database:PostgreSQL
-
Affected Branches:MOODLE_18_STABLE, MOODLE_19_STABLE
-
Fixed Branches:MOODLE_18_STABLE, MOODLE_19_STABLE
Description
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;
Attachments
Issue Links
| This issue has a non-specific relationship to: | ||||
| MDL-10181 | User Management Improvements |
|
|
|
Copied from HQ-chat:
from a syntax perspective, looks nice (but by the "$sort=''" thing in the middle) ?
anyway, I don't know if it's exactly the same behaviour that the original one (that used to search by courses having enrolperiod).
The question is: only courses with enrolperiod have the role_assignment set ?
Because you are deleting all them, no matter of the course->enrolperiod status.