CodeIgniter Forums

Full Version: SELECT GET_LOCK() showing up in slow query log (CI SESSIONS)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey All,

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

# User@Host: 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;
# User@Host: 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;
# User@Host: 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;
# User@Host: 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?
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.
@narf: Thank you for the detailed explanation, much appreciated!