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

Memcached sessions lose lock early

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: 2.6
    • Component/s: Libraries
    • Labels:
    • Testing Instructions:
      Hide

      0/ configure server to use memcached sessions
      1/ set memsession acquire timeout to 50 seconds (see config-dist.php for instructions)
      2/ crate a simple script that includes config.php and does sleep(200)
      3/ open other browser window (same browser!!!) and go to moodle page (same site!!!)
      4/ the browser should wait for 50 seconds and then continue

      Show
      0/ configure server to use memcached sessions 1/ set memsession acquire timeout to 50 seconds (see config-dist.php for instructions) 2/ crate a simple script that includes config.php and does sleep(200) 3/ open other browser window (same browser!!!) and go to moodle page (same site!!!) 4/ the browser should wait for 50 seconds and then continue
    • Affected Branches:
      MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w44_MDL-42485_m26_memcachedlocktimeout

      Description

      Memcached sessions will loose their lock after max_execution_time seconds, regardless of if Moodle later extends the time using set_time_limit(). This is because the memcached session handler uses max_execution_time to set the max lock duration at session_start().

      This means that long running scripts (like backups and restores) won't hold their session lock for long (only 30 seconds in a default php install).

      Now, because of this, there is a potential solution, you could do something like:

      public static function start() {
          $default = ini_get('max_execution_time');
          set_time_limit($CFG->session_memcached_lock_expire);
          parent::start();
          set_time_limit($default);
      }

      I fully acknowledge that this is probably horrible in many ways.

      You can see the memcached session locking logic at:
      https://github.com/php-memcached-dev/php-memcached/blob/master/php_memcached_session.c

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

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