We have recently upgraded to Moodle 3.2.4+ (Build: 20170824) from 3.1 and have since been experiencing the following errors frequently, with normal to very little load (less than 140 users). The error happens for basic navigation through the site and is not related to a specific activity like quizzes. I am not sure what could be causing it and am hoping someone can shed some light.
------------------------------
Default exception handler: Error writing to database Debug: Lock wait timeout exceeded; try restarting transaction\nUPDATE mdl_user SET lastlogin = ?,currentlogin = ?,lastaccess = ?,lastip = ? WHERE id=?\n[array (\n 0 => '1506432126',\n 1 => 1506503289,\n 2 => 1506503289,\n 3 => 'xx.xxx.xxx.xx',\n 4 => '3242',\n)]\nError code: dmlwriteexception\n* line 482 of /lib/dml/moodle_database.php: dml_write_exception thrown\n* line 1502 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()\n* line 1534 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->update_record_raw()\n* line 3219 of /lib/moodlelib.php: call to mysqli_native_moodle_database->update_record()\n* line 4427 of /lib/moodlelib.php: call to update_user_login_times()\n* line 195 of /login/index.php: call to complete_user_login()\n, referer:
-------------------------------
We are running Moodle with the application+webserver on a different server from the database server in a VMWare environment. The hardware details are:
-------------------------------
DB Server
CentOS release 6.9 (Final)
mysql Ver 15.1 Distrib 5.5.57-MariaDB, for Linux (x86_64) using readline 5.1
Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz
Memory:
total used free shared buffers cached
-/+ buffers/cache: 2304220 5756860
Swap: 8208380 40844 8167536
Mem: 8061080 4991944 3069136 8 162472 2525252
Application+Web
CentOS release 6.9 (Final)
Server version: Apache/2.2.15 (Unix)
PHP 5.6.31 (cli) (built: Jul 7 2017 08:12:50)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Intel(R) Xeon(R) CPU E5-2640 v3 @ 2.60GHz
Memory
total used free shared buffers cached
Mem: 8061080 6448624 1612456 131416 539320 3873432
-/+ buffers/cache: 2035872 6025208
Swap: 3145724 57932 3087792
I have enabled slow queries and have noticed that the Get_Lock for sessions take a long time; we are getting many of the following where the time take upwards of 120s. Each slow query log below is followed by a "Lock wait timeout" error in the Moodle Application.
-------------------------------
# Time: 170927 10:09:03
# User@Host: xxxxxxxxxx[xxxxxxxxxx] @ xxxxxxxxxx [xxxxxxxxxx]
# Thread_id: 17004 Schema: xxxxxxxxxx QC_hit: No
# Query_time: 120.000135 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
SET timestamp=1506503343;
SELECT GET_LOCK('xxxxxxxxxx-mdl_-session-6390663', 120);
# Time: 170927 10:09:06
# User@Host: xxxxxxxxxx[xxxxxxxxxx] @ xxxxxxxxxx [xxxxxxxxxx]
# Thread_id: 17012 Schema: xxxxxxxxxx QC_hit: No
# Query_time: 120.000242 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
SET timestamp=1506503346;
SELECT GET_LOCK('xxxxxxxxxx-mdl_-session-6390663', 120);
# User@Host: xxxxxxxxxx[xxxxxxxxxx] @ xxxxxxxxxx [xxxxxxxxxx]
# Thread_id: 17013 Schema: xxxxxxxxxx QC_hit: No
# Query_time: 120.000169 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
SET timestamp=1506503346;
-------------------------------
The DB variables set at startup are attached as are the top largest tables (>10MB). The mdl_logstore_standard_log table is quite large but I am not sure whether this is related to the timeout while updating the mdl_user table.
Can anyone help please?
Many thanks.