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

user_lastaccess race condition

    XMLWordPrintable

    Details

    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      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

              Assignee:
              mr-russ Russell Smith
              Reporter:
              mr-russ Russell Smith
              Peer reviewer:
              Dan Poltawski
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Ankit Agarwal
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                2/Feb/15