Issue Details (XML | Word | Printable)

Key: MDL-11160
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Nick Freear
Reporter: Nick Freear
Votes: 0
Watchers: 3
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Cron exhausts memory on "Removing expired enrolments ..."

Created: 08/Sep/07 12:29 AM   Updated: 19/Sep/07 11:40 AM
Return to search
Component/s: Database SQL/XMLDB
Affects Version/s: 1.8, 1.9
Fix Version/s: 1.8.3, 1.9

File Attachments: 1. File patch-Bug-3791-cron_memory_enrolments_2.diff (2 kB)
2. File patch-Bug-3791-cron_memory_enrolments_4.diff (2 kB)

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;
Issue Links:
Relates
 

Database: PostgreSQL
Participants: Eloy Lafuente (stronk7), Martin Dougiamas, Martín Langhoff, Nick Freear and Yu Zhang
Security Level: None
Resolved date: 14/Sep/07
Affected Branches: MOODLE_18_STABLE, MOODLE_19_STABLE
Fixed Branches: MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
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;

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Nick Freear made changes - 08/Sep/07 12:30 AM
Field Original Value New Value
Link This issue has a non-specific relationship to MDL-10181 [ MDL-10181 ]
Nick Freear made changes - 11/Sep/07 06:02 PM
Nick Freear made changes - 14/Sep/07 11:56 PM
Fix Version/s 1.8.3 [ 10230 ]
Fix Version/s 1.9 [ 10190 ]
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]