robjmills
robjmills

Reputation: 18598

Query causes mysql server to go away

We have an application that has been deployed to 50+ websites. Across these sites we have noticed a piece of strange behaviour, we have now tracked this to one specific query. Very occasionally, once or twice a day usually, one of our debugging scripts reports

2006 : MySQL server has gone away

I know there are a number of reasons this error can be thrown but the thing that is most strange is that every single time it is thrown it happens from the same SQL query being run. There is nothing strange or complex about this query, it looks like this:

SELECT `advert_only` FROM `products` WHERE `id` = '6197'

This query must run tens of thousands of times a day, for various different product IDs so it certainly doesnt fail each time. It fails randomly on seemingly random sites across our 4 servers. There is seemingly no commonality, one small thing we have noticed is that it sometimes will happen on 2 or 3 page loads in a row for 1 specific person as we also track the IP of the person it has happened to.

This is on CentOS 5 servers running MySQL 5.0.81

Upvotes: 0

Views: 974

Answers (3)

Dienow
Dienow

Reputation: 1425

That means that sql connection was idle for too long. Check if there are some slow operations performed before your sql-query.

Upvotes: 0

Daniel
Daniel

Reputation: 7172

This is kind of in left field, but you should check your harddisk SMART for any errors. If there are issues reading from "that" sector then there may be issues. If you have a raid unit I wouldn't worry too much about this. I wouldn't give a high probability to this being the problem, but if you are really stumped then it might be worth it.

Upvotes: 2

John Boker
John Boker

Reputation: 83729

on http://bugs.mysql.com/bug.php?id=1011 the second comment says that: "the 'MySQL server has gone away' error is caused by a query longer than the max_allowed_packet."

there is some more information on fixing it here: http://bogdan.org.ua/2008/12/25/how-to-fix-mysql-server-has-gone-away-error-2006.html

Upvotes: 1

Related Questions