Question

MySQL crashing without a clear error message

Posted August 7, 2014 8.8k views

I have a 64-bit droplet with 1GB on DO with LAMP installed with this tutorial.

The problem is that the error log doesn’t help me. Above is the entire error.log obtained on /var/log/mysql. I split it in two groups, the first part was the MySQL start and the second part was after crashing. There’s nothing telling me what happened for it to crash.

140807 12:53:13 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140807 12:53:13 [Note] Plugin 'FEDERATED' is disabled.
140807 12:53:13 InnoDB: The InnoDB memory heap is disabled
140807 12:53:13 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140807 12:53:13 InnoDB: Compressed tables use zlib 1.2.3.4
140807 12:53:13 InnoDB: Initializing buffer pool, size = 64.0M
140807 12:53:13 InnoDB: Completed initialization of buffer pool
140807 12:53:13 InnoDB: highest supported file format is Barracuda.
140807 12:53:13  InnoDB: Waiting for the background threads to start
140807 12:53:14 InnoDB: 5.5.35 started; log sequence number 223368867
140807 12:53:14 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
140807 12:53:14 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
140807 12:53:14 [Note] Server socket created on IP: '0.0.0.0'.
140807 12:53:14 [Note] Event Scheduler: Loaded 0 events
140807 12:53:14 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.35-0ubuntu0.12.04.2'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

(crash happened right here) <- this is not part of the log...

140807 13:35:59 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140807 13:35:59 [Note] Plugin 'FEDERATED' is disabled.
140807 13:35:59 InnoDB: The InnoDB memory heap is disabled
140807 13:35:59 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140807 13:35:59 InnoDB: Compressed tables use zlib 1.2.3.4
140807 13:35:59 InnoDB: Initializing buffer pool, size = 64.0M
140807 13:35:59 InnoDB: Completed initialization of buffer pool
140807 13:35:59 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
140807 13:35:59  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Last MySQL binlog file position 0 5216, file name /var/lib/mysql/mysql-bin.000022
140807 13:36:00  InnoDB: Waiting for the background threads to start
140807 13:36:01 InnoDB: 5.5.35 started; log sequence number 223662011
140807 13:36:01 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
140807 13:36:01 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
140807 13:36:01 [Note] Server socket created on IP: '0.0.0.0'.
140807 13:36:01 [Note] Event Scheduler: Loaded 0 events
140807 13:36:01 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.35-0ubuntu0.12.04.2'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

And here is what is on the Apache2 log that I believe is related:

[Thu Aug 07 13:34:40 2014] [error] server reached MaxClients setting, consider raising the MaxClients setting
[Thu Aug 07 13:35:59 2014] [error] [client 94.73.135.186] WordPress database error MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'carousel_enable_it' LIMIT 1 made by include('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, themepacific_Jetpack_Carousel->init, get_option, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query
[Thu Aug 07 13:35:59 2014] [error] [client 94.73.135.186] WordPress database error MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'carousel_enable_it' LIMIT 1 made by include('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, themepacific_Jetpack_Carousel->init, get_option, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query

Does anybody had the same problem? The only solution in this case is reset the droplet.

2 comments
  • You might have a memory issue, I had the same thing happen and had to add swap space to my server and later eventually upped the droplet to the next tier up.

    Eventually wordpress or drupal will use your resources and your sql will crash unless you set limits to mysql or use 3rd party tools to manage your database to optimize it. So far so good with me, make sure you create a backup or snapshot if you do not have the option to fast-resize your droplet and you want to drop down in tier to the lower level the fast-resize will adjust ram and cpu speed but not the hard disk. If you want to space on HD you’ll have to snapshot->destroy->create->my images->destroyed-> select your recently destroyed droplets and that way if you do it right away you retain your IP.

  • I’ve just run into the same problem. My mysql error log file is nearly identical, the crash seems to be triggered after table compression, however I’m not sure how this could be a resource problem for me I’m 78% of 39.25gb which gives around 9gb of available space, which I’m assuming should be enough? It’d be nice if the error logs reported the size of the compressed table files. Also my memory is never above 30%. I’ll look into this further, If I find the culprit I’ll post it.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

My SQL keep crashing on my Wordpress installation. I was only using 512mb ram though. I’ve managed to sort it using a SWAP file. Im not sure if this will fix your issue though. Give it a try.

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-12-04

by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04

Hello, all

The key error here is:

140707 23:37:13 InnoDB: Fatal error: cannot allocate memory for the buffer pool

This crash is due to your system running out of memory. I’d suggest that you add a swap file to give yourself a bit more of a buffer. Check out this tutorial:

How To Add Swap on Ubuntu 14.04

What you can also do is to use the MySQLTuner script.

The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

To run the script you could do the following:

  • SSH to your Droplet
  • Download the script:
wget http://mysqltuner.pl/ -O mysqltuner.pl
  • Then execute it:
perl mysqltuner.pl

The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

On the same note, if you want to have a worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

https://www.digitalocean.com/products/managed-databases-mysql/

This was mini tutorial was posted from @bobbyiliev in this question in our community: https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

Hope that this helps!
Regards,
Alex

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
Submit an Answer