I have a server running web site with back-end database MySQL (more specific – 5.5.37-MariaDB, for debian-linux-gnu on x86_64).
Sometimes it stops accepting connections and web site scripts report "unable to connect to the server". After I restart MySQL server it works ok for some time (up to several days).
syslog, mysql.error and dmesg show no related errors. slow-query log however shows that at some moment queries are executed slower and slower (starting from about 1 second and ending at 70). After I restart MySQL same queries are executed immediately.
How can I fix it or at least define issue cause?
Best Answer
When the server is hanging run
strace -fp <pid of mysql>
That will show which command is waiting. Its likely to be a read with a number
lsof -p <mysql pid>
will display what that number actually is.Its hard to say without being on the server when its breaking if there is nothing else to go off in the logs