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

Potential race condition when inserting a context record

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: BACKEND
    • Fix Version/s: None
    • Component/s: Libraries
    • Labels:
      None

      Description

      In version 20, function get_sustem_context() in file lib/accesslib.php, a context record is checked if exists and then inserted. However, when concurrent requests insert the same context record, a duplicate key database error will be raised. When handling the error, the function should not just return null. Instead, we could check if the record already exists in the database and return the record. The same problem exists in version 32 when I tested. I searched in the latest version and the problem also exists there.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            Case_qiu CaseKK
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: