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

Serious performance regression in course reset of groups, including race condition that may send erroneous emails to students

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: 2.6
    • Component/s: Groups, Quiz
    • Labels:
    • Testing Instructions:
      Hide

      Test pre-requisites

      1. Create some groups (A, B), and add some users to the group
        • 2 member of group A (let's call them M1, M2)
        • 2 not being in a group (let's call them M3, M4)
      2. Create a quiz with a close date set (in the future)
      3. Add a group override of group A that removes the close date
      4. Open the quiz page logged in as the above users to observe if a closed date is mentioned.
        • You can confirm that M3 and M4 have a closed date, M1 and M2 don't.

      Test 1

      1. Now add M3 to group A
        • Make sure M3 inherited the new override (no close date)
      2. Remove M1 from group A
        • Make sure M1 inherited the new override (now has a closed date)
      3. Delete group A
        • Make sure M2 and M3 inherited the new override (now has a closed date)

      Test 2

      1. Re-set the environment according to the test-prerequisites
      2. Perform a course reset, only select Remove all group members.
      3. Make sure M1 and M2 inherited the override (now have a closed date)

      Test 3

      1. Re-set the environment according to the test-prerequisites
      2. Perform a course reset, only select Delete all groups.
      3. Make sure M1 and M2 inherited the override (now have a closed date)
      Show
      Test pre-requisites Create some groups (A, B), and add some users to the group 2 member of group A (let's call them M1, M2) 2 not being in a group (let's call them M3, M4) Create a quiz with a close date set (in the future) Add a group override of group A that removes the close date Open the quiz page logged in as the above users to observe if a closed date is mentioned. You can confirm that M3 and M4 have a closed date, M1 and M2 don't. Test 1 Now add M3 to group A Make sure M3 inherited the new override (no close date) Remove M1 from group A Make sure M1 inherited the new override (now has a closed date) Delete group A Make sure M2 and M3 inherited the new override (now has a closed date) Test 2 Re-set the environment according to the test-prerequisites Perform a course reset, only select Remove all group members . Make sure M1 and M2 inherited the override (now have a closed date) Test 3 Re-set the environment according to the test-prerequisites Perform a course reset, only select Delete all groups . Make sure M1 and M2 inherited the override (now have a closed date)
    • Affected Branches:
      MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-41726-master-2nd
    • Story Points:
      100
    • Sprint:
      BACKEND Sprint 5

      Description

      Steps to reproduce

      1. Create a large course, say with 10,000 users, a few dozen groups each with a few thousand members, and several quizzes. (The OU has courses this big.)
      2. Time doing a course reset to remove all group members. (Also look at the DB query count in the footer.)

      Do this for Moodle versions both before and after MDL-39958 was integrated. (Note that MDL-39958 was committed with MDL-39959 is the issue id in the commit comment.)

      That is the perofrmance problem. Now the nasty race condition.

      1. Work out which order $DB->get_recordset('groups', array('courseid' => $courseid)); in groups_delete_group_members, in particular identify which goup will be deleted first, and which last.
      2. For one quiz, set Time limits as follows:
        • Quiz closes: Now + 1 day
        • Quiz closes group override for last group to be processed: Now - 1 day
        • Quiz closes group override for first group to be processed: Now + 1 day
      3. Set the quiz to have attempts become overdue when time expires, and to send an email notification to student when this happens.
      4. Start an attempt as one student that is a member of both those groups. Answer some questions but don't submit.
      5. Now, try to work out when cron will next run, and just beofre that, do a course reset to remove all the group members, Now also need to be between T + 1 minute and T + 1 day.

      Expected result: The student does not get a notification, because initially the close date is Now + 1 day, and when they are removed from both groups it is Now + 1 day.

      Possible result:
      Cron runs between time the student is removed from the first group, and the time they are removed from the last group. Hence cron sees them as due to submit T - 1 day ago, and so makes their attempt overdue, and sends them an incorrect email.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/13