Moodle 3.2 - Memcached Session Handling PHP 7.0.9

Re: Moodle 3.2 - Memcached Session Handling PHP 7.0.9

by Jeff White -
Number of replies: 1
Hi Michael, 


I have an environment using the same PHP and Moodle version as you are using and did not have errors like that using Redis. 

In reply to Jeff White

Re: Moodle 3.2 - Memcached Session Handling PHP 7.0.9

by TC TC -

We have tried to use Redis as session cache and it has problems with session locking too:


[23-Mar-2018 09:01:06 Europe/Madrid] Cannot obtain session lock for sid: 6678dv8u0g7t26o1e2jfh78o7k within 120. It is likely another page has a long session lock, or the session lock was never released.

[23-Mar-2018 09:01:06 Europe/Madrid] Default exception handler: error/Unable to obtain session lock Debug:

Error code: Unable to obtain session lock

$a contents:

* line 366 of /lib/classes/session/redis.php: core\session\exception thrown

* line 258 of /lib/classes/session/redis.php: call to core\session\redis->lock_session()

* line ? of unknownfile: call to core\session\redis->handler_read()

* line 42 of /lib/classes/session/handler.php: call to session_start()

* line 124 of /lib/classes/session/redis.php: call to core\session\handler->start()

* line 77 of /lib/classes/session/manager.php: call to core\session\redis->start()

* line 785 of /lib/setup.php: call to core\session\manager::start()

* line 405 of /config.php: call to include_once()

* line 30 of /index.php: call to require_once()


Our configuration for redis is as follows:


#$CFG->session_handler_class = '\core\session\redis';

#$CFG->session_redis_host = 'xxxxxx';

#$CFG->session_redis_port = 6379;  // Optional.

#$CFG->session_redis_database = 0;  // Optional, default is db 0.

#$CFG->session_redis_prefix = $CFG->dbname.'.sess.key.'; // Optional, default is don't set one.

#$CFG->session_redis_acquire_lock_timeout = 120;

#$CFG->session_redis_lock_expire = 7200;

#$CFG->session_redis_serializer_use_igbinary = true;


We have tried to use memcached with the following configuration but we have problems with session locking too:


$CFG->session_handler_class = '\core\session\memcached';

$CFG->session_memcached_save_path = 'xxxx:xxxx;

$CFG->session_memcached_prefix = $CFG->dbname.'.sess.key.';

$CFG->session_memcached_acquire_lock_timeout = 120;

$CFG->session_memcached_lock_expire = 7200;       // Ignored if memcached extension <= 2.1.0

$CFG->session_memcached_lock_retry_sleep = 150;   // Spin-lock retry sleeptime (msec). Only effective


and we have added the following to the apache php.ini config file:


session.lazy_write = 0


Do you have any clue regarding session locking handling?


Thank you very much in advance