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

CLONE - Duplicate session insertion

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.6.1
    • Fix Version/s: STABLE backlog
    • Component/s: Libraries
    • Labels:
    • Environment:
      Using Percona Cluster
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_26_STABLE

      Description

      On moodle.org, we are getting lots of 'Can not read or insert database sessions'.

      Upon investigation I see that this is caused by a duplciate key violation 'Looks like duplivate violation: ''error' => 'Duplicate entry
      'hlk0s2o8fqrmr6k1pijcp3uvi3
      ' for key \\'sess_sid_uix\\'',\n''.

      So.. it looks to me like this bit of code should be wrapped in a transaction, because presumably another request is inserting the sesion record in between:

       if (!$record = $this->database->get_record('sessions', array('sid'=>$sid))) {
                      $record = new stdClass();
                      $record->state        = 0;
                      $record->sid          = $sid;
                      $record->sessdata     = null;
                      $record->userid       = 0;
                      $record->timecreated  = $record->timemodified = time();
                      $record->firstip      = $record->lastip = getremoteaddr();
                      $record->id           = $this->database->insert_record_raw('sessions', $record);
                  }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                moodle.com moodle.com
                Reporter:
                modguru Jai Gupta
                Participants:
                Component watchers:
                Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: