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

user_lastaccess race condition

    XMLWordPrintable

Details

    • MOODLE_25_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • Hide

      The only way I found to test the race condition was to manually insert a sleep of 60 seconds into the before the insert_record_raw call just after lib/datalib.php:1700.

      So to test the race condition;
      1. Insert the sleep(60) in lib/datalib.php just before insert_record_raw
      2. Open browser as an admin.
      3. Create a new user.
      4. Enrol that user in a course, existing or new.
      5. Logout as admin
      6. Open two browsers and login as the newly created user.
      7. In EACH of the browsers, click on the course they are enrolled in.
      8. Confirm both pages load without logging an exception.
      9. Verify the last access time is correct.

      Show
      The only way I found to test the race condition was to manually insert a sleep of 60 seconds into the before the insert_record_raw call just after lib/datalib.php:1700. So to test the race condition; 1. Insert the sleep(60) in lib/datalib.php just before insert_record_raw 2. Open browser as an admin. 3. Create a new user. 4. Enrol that user in a course, existing or new. 5. Logout as admin 6. Open two browsers and login as the newly created user. 7. In EACH of the browsers, click on the course they are enrolled in. 8. Confirm both pages load without logging an exception. 9. Verify the last access time is correct.

    Description

      There is a race condition in user_lastaccess updates. Two insert attempts can be made at the one time. This is not usually an issue as a single user is not operating on the same course at the same time when it's not been accessed before.

      However with webservices, it's possible to have two calls to a new course and they bump into each other.

      Attachments

        Issue Links

          Activity

            People

              mr-russ Russell Smith
              mr-russ Russell Smith
              Dan Poltawski Dan Poltawski
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Ankit Agarwal Ankit Agarwal
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                2/Feb/15