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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8, 1.9
    • Fix Version/s: 1.8.3, 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

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Oct/07