CodeIgniter Forums
SELECT GET_LOCK() showing up in slow query log (CI SESSIONS) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: SELECT GET_LOCK() showing up in slow query log (CI SESSIONS) (/showthread.php?tid=64893)



SELECT GET_LOCK() showing up in slow query log (CI SESSIONS) - heat23 - 04-08-2016

Hey All,

My database is tuned pretty well overall but I am seeing statements like this in my MySQL slow query log:

# [email protected]: heatware_dotcom[heatware_dotcom] @ localhost []  Id: 91681
# Query_time: 1.086505  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1460134851;
SELECT GET_LOCK('a7642ffa05034f140c3fc90be7efd272828a600a', 300) AS ci_session_lock;
# [email protected]: heatware_dotcom[heatware_dotcom] @ localhost []  Id: 91682
# Query_time: 1.112502  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1460134851;
SELECT GET_LOCK('a7642ffa05034f140c3fc90be7efd272828a600a', 300) AS ci_session_lock;
# [email protected]: heatware_dotcom[heatware_dotcom] @ localhost []  Id: 91683
# Query_time: 1.132454  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1460134851;
SELECT GET_LOCK('a7642ffa05034f140c3fc90be7efd272828a600a', 300) AS ci_session_lock;
# [email protected]: heatware_dotcom[heatware_dotcom] @ localhost []  Id: 91684
# Query_time: 1.165734  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1460134851;
SELECT GET_LOCK('a7642ffa05034f140c3fc90be7efd272828a600a', 300) AS ci_session_lock;

My website is NOT high traffic and may only have a handful of users online concurrently. My ci_sessions table is setup for INNODB although, I did not see these GET_LOCK() slow queries when I temporarily switched it over to MyISAM.

Any ideas why these are showing up in slow query log?


RE: SELECT GET_LOCK() showing up in slow query log (CI SESSIONS) - Narf - 04-08-2016

You can just ignore this.

It's caused by the same user attempting to simultaneously load multiple pages (or one page with asynchronous AJAX calls) on your website. And it's exactly what is supposed to happen - wait for the lock to be freed (session closed on one page) before being able to acquire a lock for the second page load.

Concurrent users and the database engine are irrelevant. You didn't see this on MyISAM just because you didn't have a user with the same behavior during that temporary switch.


RE: SELECT GET_LOCK() showing up in slow query log (CI SESSIONS) - heat23 - 04-08-2016

@narf: Thank you for the detailed explanation, much appreciated!