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

Memcache session support does not work for multiple servers

    XMLWordPrintable

    Details

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

      NOTE: You need an instance of the memcached server running in order to carry out this test. The instructions here assume it is running on localhost on the default port.

      This test requires access to temporarily modify Moodle code.

      1. In server settings, edit config.php to add the following (after or instead of any existing session handler code):

      $CFG->session_handler_class = '\core\session\memcache';
      $CFG->session_memcache_save_path = '127.0.0.1:11211,localhost:11211';
      $CFG->session_memcache_acquire_lock_timeout = 120;
      

      Note that this has a list of 2 memcache servers which are actually both the same server. If you have 2 real servers feel free to use different ones, but the same one twice is enough to demonstrate the bug.

      2. Visit your Moodle and log in. Click around for a couple of pages (e.g. in the admin screens).

      EXPECTED: You remain logged in (the session is working).

      3. Edit the config.php to change the line to:

      $CFG->session_memcache_save_path = 'tcp://127.0.0.1:11211,tcp://localhost:11211';
      

      This is the 'raw' format which some people might mistakenly use.

      4. Visit Moodle again.

      EXPECTED: You should get a session configuration error. If you have debugging on, you'll see the explanation that you need to not include tcp:// in the variable.

      Show
      NOTE: You need an instance of the memcached server running in order to carry out this test. The instructions here assume it is running on localhost on the default port. This test requires access to temporarily modify Moodle code. 1. In server settings, edit config.php to add the following (after or instead of any existing session handler code): $CFG->session_handler_class = '\core\session\memcache'; $CFG->session_memcache_save_path = '127.0.0.1:11211,localhost:11211'; $CFG->session_memcache_acquire_lock_timeout = 120; Note that this has a list of 2 memcache servers which are actually both the same server. If you have 2 real servers feel free to use different ones, but the same one twice is enough to demonstrate the bug. 2. Visit your Moodle and log in. Click around for a couple of pages (e.g. in the admin screens). EXPECTED: You remain logged in (the session is working). 3. Edit the config.php to change the line to: $CFG->session_memcache_save_path = 'tcp://127.0.0.1:11211,tcp://localhost:11211'; This is the 'raw' format which some people might mistakenly use. 4. Visit Moodle again. EXPECTED: You should get a session configuration error. If you have debugging on, you'll see the explanation that you need to not include tcp:// in the variable.
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE
    • Pull Master Branch:
      MDL-45260-master

      Description

      We have been doing more testing of MDL-43975 and have discovered that it fails if you specify multiple servers because the configuration format is not the same as for memcached.

      There should be code that corrects the format (so we can use the same config.php format for both types and have it work correctly).

      The specific failure (using the test instructions given above) is:

      Fatal error: session_start(): Failed to initialize storage module: memcache (path: 127.0.0.1:11211,localhost:11211)
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/May/14