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

Extra session lock debugging for redis session handler

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Waiting for peer review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: Future Dev
    • Fix Version/s: None
    • Component/s: Performance
    • Testing Instructions:
      Hide

       

      1) Setup redis

      2) Setup redis as the session handler:

       

      $CFG->session_redis_host = '127.0.0.1';
      $CFG->session_redis_port = 6379; // Optional.
      $CFG->session_redis_acquire_lock_timeout = 5;
      $CFG->session_handler_class = '\core\session\redis';
      

      3) Write a dud script that hangs onto the session for ages /long-session.php

      <?php
      require('config.php');
      require_login();
      sleep(10);
      

       

      4) Open that script and login

      5) tail the logs with debugging on

      6) then open it in two tabs at the same time in fast succession within 5 seconds

      http://moodle.local/long-session.php?id=1

      http://moodle.local/long-session.php?id=2

       

      You should see an error log like:

      Cannot obtain session lock for sid: a5u30psl4he2t3sqpkroghucbj within 5 seconds. It is likely another page (zebrafish:25101 /long-session.php?id=1) has a long session lock, or the session lock was never released.

       

       

      Show
        1) Setup redis 2) Setup redis as the session handler:   $CFG->session_redis_host = '127.0.0.1' ; $CFG->session_redis_port = 6379 ; // Optional. $CFG->session_redis_acquire_lock_timeout = 5 ; $CFG->session_handler_class = '\core\session\redis' ; 3) Write a dud script that hangs onto the session for ages /long-session.php <?php require( 'config.php' ); require_login(); sleep( 10 );   4) Open that script and login 5) tail the logs with debugging on 6) then open it in two tabs at the same time in fast succession within 5 seconds http://moodle.local/long-session.php?id=1 http://moodle.local/long-session.php?id=2   You should see an error log like: Cannot obtain session lock for sid: a5u30psl4he2t3sqpkroghucbj within 5 seconds. It is likely another page (zebrafish:25101 /long-session.php?id=1) has a long session lock, or the session lock was never released.    
    • Pull Master Branch:
      MDL-67075-redis-session-locks

      Description

      This adds more debugging to make it easier to track down open session locks.

      Note this is superficially similar to MDL-64449 but with a couple key differences. Firstly that one mutates the session which means more churning. Secondly it only works after the fact, if you have a blocked session you can't see what's blocking you right now. More importantly it also doesn't work if the session lock times out, for it to work you must eventually gain the session lock to get access to what's inside the session data.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                brendanheywood Brendan Heywood
                Reporter:
                brendanheywood Brendan Heywood
                Participants:
                Component watchers:
                Matteo Scaramuccia, Jake Dallimore, Jun Pataleta
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: