Timed out while waiting for session lock

Timed out while waiting for session lock

by Nathan Friend -
Number of replies: 9

Hello,

We have recently upgraded from 1.9.9 to 2.2.4.  Occasionly i'm getting "Timed out while waiting for session lock" in the apache error log I'm getting: 

[Thu Jul 26 12:15:02 2012] [error] [client 10.18.10.44] Default exception handler: Timed out while waiting for session lock.<br />Wait for your current requests to finish and try again later.

Debug: \n* line 1228 of /lib/dml/mysqli_native_moodle_database.php: dml_sessionwait_exception thrown\n*
line 593 of /lib/sessionlib.php: call to mysqli_native_moodle_database->get_session_lock()\n
* line ? of unknownfile: call to database_session->handler_read()\n* line 184 of /lib/sessionlib.php: call to session_start()\n
* line 473 of /lib/sessionlib.php: call to session_stub->__construct()\n* line 60 of /lib/sessionlib.php: call to database_session->__construct()\n
* line 692 of /lib/setup.php: call to session_get_instance()\n* line 469 of /config.php: call to require_once()\n
* line 31 of /index.php: call to require_once()\n

Any ideas how to solve this?

 

Cheers,

 

Nathan.

Average of ratings: -
In reply to Nathan Friend

Re: Timed out while waiting for session lock

by Ken Task -
Picture of Particularly helpful Moodlers

Just guessing ... and a suggestion as to what to try (which can be reversed) ... sounds like you're remotely hosted and there could be some issues with remotely hosted hits on the database for version 2 (am taking a clue from 'lock' mentioned above).

1.9.x sessions wrote to a file in the sessions folder of your data folder to record sessions.  If I re-called correctly, 2.x defaults to using the database for session information when a user logs on.

In Site Admin menu -> Server -> Session Handling is the first check box checked?  If so, it's using the DB.  Uncheck.  That action, BTW, will immediately log you out and you'll have to log back in - which is normal.

Might also use a different Cookie Prefix from that which was the old 1.9.x.  Also clear cookies for the site from the browser.

Your data folder for the 2 should then include a sessions folder.  It, of course, has to be readable/writeable by the apache user/group and Moodle should create the directory for you if it doesn't exist - with correct permissions.

Just to check however, in it, one will see files something like this:

[root@moodle kensmoodle2data]# ls -ld sessions
drwxrwxrwx 2 apache apache 81920 Jul 26 08:23 sessions

[root@moodle kensmoodle2data]# cd sessions
[root@moodle sessions]# ll
total 64
-rw------- 1 apache apache 1835 Jul 26 06:34 sess_4ntg0h69d6iau9qt70471gvgj7

Should add that one could remove those 'sess_ASDFASF...' files manually (which is sorta like removing cookies from browser) via command line.  That action will auto logout all users connected at the time and force them to login again - thus acquiring also the new cookie upon logging in again.

'spirit of sharing', Ken

In reply to Ken Task

Re: Timed out while waiting for session lock

by Nathan Friend -

Hi Ken,
Thanks for replying.  We host our moodle on site.  We did use database session handling on 1.9 without problems.  However I'm going to go back to disk based as an experiment.  As the moodledata directory is on NFS I've symlinked the sessions direcotry to a local directory to prevent problems with NFS file locking.

Hopefully all will be well now, but it would be nice to know what was going wrong with the database session handling.

 

Cheers,

 

Nathan.

 

In reply to Nathan Friend

Re: Timed out while waiting for session lock

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Can we - once again - get some information about your system..
- Operating system
- Web server (version)?
- MySQL version?
- PHP version?

This could be caused by your system overloading? What is the spec of your server? How many users were using it at the time and what, roughly, where they doing? Have you done any performance tuning of Apache or MySQL?
In reply to Howard Miller

Re: Timed out while waiting for session lock

by Nathan Friend -

SLES 11.2
Apache 2.2.12
MySQL 5.5.2.5
PHP 5.3.8


4 Web, 1 NFS, 1 DB servers.  All have plently of RAM/CPU, free.
About 13000 users but only a handfull logged in at the moment.  Mainly updaing course content.
I have made a few changes to the apache/MySQL config but would like to hear your tuning suggestions.

In reply to Nathan Friend

Re: Timed out while waiting for session lock

by Ken Task -
Picture of Particularly helpful Moodlers

Since I started may as well stay in the discussion, but will say this up front ... defer what I respond with recommendations, etc. to what Howard makes! ;)

Would think tuning MySQL is difficult to do without seeing/knowing from a first hand perspective, thus how about using this:

http://www.howtoforge.com/tuning-mysql-performance-with-mysqltuner

From what experience I've had with backups to a Windows share via mounts, it's slow ... and would imagine NFS 'tuning' is also in order.
And that's both ends ... the web server and the NFS box.  Does SuSE have any documents/FAQ's etc. for such?

This may/may not be of help:

http://www.softpanorama.info/Commercial_linuxes/Suse/suse_performance_tuning.shtml

'spirit of sharing', Ken

In reply to Nathan Friend

Re: Timed out while waiting for session lock

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Well... hmmm... what do you call a "handful" of users?

MySQL "out of the packet" is usually set up very conservatively so it doesn't run away with all your memory. Obviously, if it is sitting on its own box that's pretty much what you want it to do.

I'm not sure I'm a great expert but there are loads of resources online and a perl script (http://mysqltuner.pl/mysqltuner.pl) that is really handy.

My point is, that you might think of 20 users as a handful but that could quite easily chew up a badly setup database server.

As you say you could switch to storing sessions in NFS... but... how fast is your NFS?
In reply to Howard Miller

Re: Timed out while waiting for session lock

by Nathan Friend -

Thanks for the sugestions.  I'll give the tuning script a try.

B.T.W I've symblinked the sessions directoy to the local disk so NFS is not being used for the session files.

In reply to Nathan Friend

Re: Timed out while waiting for session lock

by Nathan Friend -

Hello,

I've followed the mysqltuner scripts sugestions.  There are still a couple of warnings 

[!!] Joins performed without indexes: 5857

[!!] Temporary tables created on disk: 43% (82K on disk / 188K total)

With the sugestion to increase the following:

join_buffer_size (> 256.0K, or always use indexes with joins)
tmp_table_size (> 64M)
max_heap_table_size (> 64M)
table_cache (> 512)

Any sugesions on values, what values do you have set on your installaions? 

Cheers,

 

Nathan.

In reply to Nathan Friend

תשובה ל: Re: Timed out while waiting for session lock

by Raphael Goldman -

Hi,

I have the same problem with the Timed out while waiting for session lock

How did you solve it?

Thanks,

Raphael