Users cannot view or send messages - "Error reading from database"

Users cannot view or send messages - "Error reading from database"

by Virangya Senevirathne -
Number of replies: 1

Hello,

We had issues with a corrupted database in moodle 2.7 and data has been restored from two weeks old backup. Another failure happened and now users cannot view or send messages. This is the screenshot of what the issue looks like for every user when he/she navigate into "send a message" link on a user profile.

error reading database

I turned "debugging on" and got these errors on the screen.

Warning:
 mysqli::query(): MySQL server has gone away in 
/usr/local/www/cdcebba.pdn.ac.lk/lib/dml/mysqli_native_moodle_database.php
 on line 1079

Warning: mysqli::query(): Error reading result set's header in 
/usr/local/www/cdcebba.pdn.ac.lk/lib/dml/mysqli_native_moodle_database.php
 on line 1079
Error reading from database
More information about this error
Debug info: MySQL server has gone away
SELECT * FROM mdl_message_read WHERE ((useridto = ? AND useridfrom = ?) OR
(useridto = ? AND useridfrom = ?)) AND NOT (useridfrom=? AND notification=1) ORDER BY timecreated desc LIMIT 0, 8
[array (
0 => '3',
1 => '58',
2 => '58',
3 => '3',
4 => '3',
)]
Error code: dmlreadexception
Stack trace: 
  • line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1305 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1948 of /message/lib.php: call to moodle_database->get_records_select()
  • line 2031 of /message/lib.php: call to message_get_history()
  • line 296 of /message/index.php: call to message_print_message_history()

Any help on this regard is very much appreciated.  Looking forward to quick replies.


Many thanks in advance.

Average of ratings: -
In reply to Virangya Senevirathne

Re: Users cannot view or send messages - "Error reading from database"

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The "MySQL server has gone away" message tends to be a result of timeouts in MySQL (or MariaDB). If you run the following command in the MySQL shell or in phpMyAdmin and reply with the results: SHOW GLOBAL VARIABLES WHERE variable_name IN ('wait_timeout', 'max_allowed_packet', 'net_read_timeout', 'net_write_timeout');

The values on my system are:

+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 4194304 |
| net_read_timeout   | 30      |
| net_write_timeout  | 60      |
| wait_timeout       | 28800   |
+--------------------+---------+

There are posts on here suggesting increasing max_allowed_packet to 512 MB.

I should say that these timeouts would come into play if clicking on "send a message" is taking a long time. If it is there may be an error in the database table (possibly related to the corrupted database issue). Find out where your MySQL/MariaDB logs are (mine are in /var/log/mariadb/mariadb.log, yours may be somewhere else) and check these for errors. You may need to repair a table.

Average of ratings: Useful (1)