MySQL 5.5 - Lost connection to MySQL server during query

Posted by bully on Ask Ubuntu See other posts from Ask Ubuntu or by bully
Published on 2012-09-21T06:12:41Z Indexed on 2012/09/21 9:50 UTC
Read the original article Hit count: 1000

Filed under:

I have an Ubuntu 12.04 LTS server running at a german hoster (virtualized system).

# uname -a 
Linux ... 3.2.0-27-generic #43-Ubuntu SMP Fri Jul 6 14:25:57 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

I want to migrate a Web CMS system, called Contao. It's not my first migration, but my first migration having connection issues with mysql.

Migration went successfully, I have the same Contao version running (it's more or less just copy / paste).

For the database behind, I did:

apt-get install mysql-server phpmyadmin

I set a root password and added a user for the CMS which has enough rights on its own database (and only its database) for doing the stuff it has to do. Data import via phpmyadmin worked just fine.

I can access the backend of the CMS (which needs to deal with the database already).

If I try to access the frontend now, I get the following error:

Fatal error: Uncaught exception Exception with message Query error: 
Lost connection to MySQL server during query (<query statement here, nothing special, just a select>) thrown in /var/www/system/libraries/Database.php on line 686

(Keep in mind: I can access mysql with phpmyadmin and through the backend, working like a charme, it's just the frontend call causing errors).

If I spam F5 in my browser I can sometimes even kill the mysql deamon.

If I run

# mysqld --log-warnings=2

I get this:

...
120921  7:57:31 [Note] mysqld: ready for connections.
Version: '5.5.24-0ubuntu0.12.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
05:57:37 UTC - mysqld got signal 4 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=1
max_threads=151
thread_count=1
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 346679 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7f1485db3b20
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f1480041e60 thread_stack 0x30000
mysqld(my_print_stacktrace+0x29)[0x7f1483b96459]
mysqld(handle_fatal_signal+0x483)[0x7f1483a5c1d3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0)[0x7f1482797cb0]
/lib/x86_64-linux-gnu/libm.so.6(+0x42e11)[0x7f14821cae11]
mysqld(_ZN10SQL_SELECT17test_quick_selectEP3THD6BitmapILj64EEyyb+0x1368)[0x7f1483b26cb8]
mysqld(+0x33116a)[0x7f148397916a]
mysqld(_ZN4JOIN8optimizeEv+0x558)[0x7f148397d3e8]
mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select_lex+0xdd)[0x7f148397fd7d]
mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x17c)[0x7f1483985d2c]
mysqld(+0x2f4524)[0x7f148393c524]
mysqld(_Z21mysql_execute_commandP3THD+0x293e)[0x7f14839451de]
mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x10f)[0x7f1483948bef]
mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1365)[0x7f148394a025]
mysqld(_Z24do_handle_one_connectionP3THD+0x1bd)[0x7f14839ec7cd]
mysqld(handle_one_connection+0x50)[0x7f14839ec830]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a)[0x7f148278fe9a]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f1481eba4bd]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7f1464004b60): is an invalid pointer
Connection ID (thread ID): 1
Status: NOT_KILLED

From /var/log/syslog:

Sep 21 07:17:01 s16477249 CRON[23855]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Sep 21 07:18:51 s16477249 kernel: [231923.349159] type=1400 audit(1348204731.333:70): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=23946 comm="apparmor_parser"
Sep 21 07:18:53 s16477249 /etc/mysql/debian-start[23990]: Upgrading MySQL tables if necessary.
Sep 21 07:18:53 s16477249 /etc/mysql/debian-start[23993]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
Sep 21 07:18:53 s16477249 /etc/mysql/debian-start[23993]: Looking for 'mysql' as: /usr/bin/mysql
Sep 21 07:18:53 s16477249 /etc/mysql/debian-start[23993]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Sep 21 07:18:53 s16477249 /etc/mysql/debian-start[23993]: This installation of MySQL is already upgraded to 5.5.24, use --force if you still need to run mysql_upgrade
Sep 21 07:18:53 s16477249 /etc/mysql/debian-start[24004]: Checking for insecure root accounts.
Sep 21 07:18:53 s16477249 /etc/mysql/debian-start[24009]: Triggering myisam-recover for all MyISAM tables

I'm using MyISAM tables all over, nothing with InnoDB there. Starting / stopping mysql is done via

sudo service mysql start
sudo service mysql stop

After using google a little bit, I experimented a little bit with timeouts, correct socket path in the /etc/mysql/my.cnf file, but nothing helped. There are some old (from 2008) Gentoo bugs, where re-compiling just solved the problem. I already re-installed mysql via:

sudo apt-get remove mysql-server mysql-common
sudo apt-get autoremove
sudo apt-get install mysql-server

without any results.

This is the first time I'm running into this problem, and I'm not very experienced with this kind of mysql 'administration'.

So mainly, I want to know if anyone of you could help me out please :)

Is it a mysql bug? Is something broken in the Ubuntu repositories? Is this one of those misterious 'use-tcp-connection-instead-of-socket-stuff-because-there-are-problems-on-virtualized-machines-with-sockets'-problem? Or am I completly on the wrong way and I just miss-configured something? Remember, phpmyadmin and access to the backend (which uses the database, too) is just fine. Maybe something with Apache? What can I do?

Any help is appreciated, so thanks in advance :)

© Ask Ubuntu or respective owner

Related posts about mysql