Joy of joys, my server is crashes for some ungodly reason, and it took out my MySQL server. Arg… The damn thing won’t start at all, it crashes badly everytime I start it. And it gives me a big, fat crash message, and even the backtrace is broken:
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
080811 15:51:19 InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 3 2057517825.
InnoDB: Doing recovery: scanned up to log sequence number 3 2057578233
080811 15:51:19 InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 mysqld got signal 11;
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=0
read_buffer_size=131072
max_used_connections=0
max_connections=100
threads_connected=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 217599 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
thd=(nil)
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...
Cannot determine thread, fp=0xb511d4a8, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x81c06b9
0x83cba12
0x83cc69b
0x8390215
0x8392120
0x837f38a
0x83aa73c
0x82f0308
0xb7ed10bd
0xb7d0c01e
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/using-stack-trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.
But thankfully, this MySQL was running on Debian. So through the magic of apt, I got everything running again. Basically, I renamed the key folders, then I purged MySQL server and reinstalled it, even deleting the databases (since they were moved elsewhere anyway):
mv /var/lib/mysql /var/lib/mysql-old
mv /var/log/mysql /var/log/mysql-old
aptitude purge mysql-server mysql-server-5.0
aptitude install mysql-server
Ok, now at least mysqld starts. Then I switched back the original files, keeping the Debian generated one, just in case:
/etc/init.d/mysql stop
mv /var/lib/mysql /var/lib/mysql-deb
mv /var/log/mysql /var/log/mysql-deb
mv /var/lib/mysql-old /var/lib/mysql
mv /var/log/mysql-old /var/log/mysql
/etc/init.d/mysql start
Wow, it worked… I wonder how borked the data is, it’s time for a backup, then we’ll see…. ah, scheiße, there is more recover pain to endure. Hmm… first one is a simple one. I tried deleting some cruft databases, but it wasn’t fully deleting them. And none of the databases were showing up in phpMyAdmin or SHOW DATABASES;. Turns out the perms were wrong. This helped that problem:
chown mysql.mysql /var/lib/mysql/
Ok, things were going swimmingly, until I got an error #1 - Can't create/write to file '/tmp/#sql_3c2e_0.MYI' (Errcode: 13). Crazy ass shit. Turns out that /tmp had strange permissions, only root can write:
root@blinky:mysql > ls -ld /tmp/
drwxr-xr-x 17 root root 262144 2008-08-11 18:19 /tmp//
So I rectified that with a little chmod 1777 /tmp/, but now, WTF!??!, mysql crashes again on startup, with the same error!