[geeklog-devel] Geeklog - Locking the Session table

Tom websitemaster at cogeco.net
Fri Nov 1 21:24:23 EDT 2013


On my live Geeklog 2.1.0 site a see a few deadlock errors every couple of
days. Here are the 2 examples:

An SQL error has occurred. Please see error.log for details. @
C:\inetpub\geeklog\system\databases\mysqli.class.php line 279 
1213: Deadlock found when trying to get lock; try restarting transaction in
C:\inetpub\geeklog\system\lib-sessions.php:336. SQL in question: DELETE FROM
gl_sessions WHERE (start_time < 1379748688) 

256 - An SQL error has occurred. Please see error.log for details. @
C:\inetpub\geeklog\system\databases\mysqli.class.php line 279 
1213: Deadlock found when trying to get lock; try restarting transaction in
C:\inetpub\geeklog\system\lib-sessions.php:486. SQL in question: UPDATE
gl_sessions SET start_time = 1379785338, whos_online = 1 WHERE (md5_sess_id
= 'a16f14f7db6601529da31738be7d4d9b')

They obviously involve the Geeklog Sessions, deleting expired sessions and
updating ones who are online.

For comments I know we lock the whole table before updating like so:

DB_lockTable ($_TABLES['comments']);

...

DB_unlockTable($_TABLES['comments']);

Should we do this when we delete sessions? I believe this check is done on
every page load so I am not sure if we  will create more issues (or longer
wait periods) by locking the entire table every single time. 

MySQL suggests

http://dev.mysql.com/doc/refman/5.5/en/innodb-deadlocks.html

we should just rerun the query when this happens. (which we currently can't
because an error is triggered)

Does anyone have any experience dealing with these type of issues?

Tom




More information about the geeklog-devel mailing list