Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-11160

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8, 1.9
    • 1.8.3, 1.9
    • Database SQL/XMLDB
    • None
    • The following SQL on the OU's live system returned count = 176574,
          SELECT COUNT(*) FROM mdl_role_assignments WHERE timeend > 0 AND timeend < 1189123200;
    • PostgreSQL
    • MOODLE_18_STABLE, MOODLE_19_STABLE
    • 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

          Activity

            People

              nfreear Nick Freear
              nfreear Nick Freear
              Nobody Nobody
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                11/Oct/07