View Full Version : lost connection to mysql
ryanlwh
01-23-2006, 04:48 PM
Hey guys,
I recently transferred by site to 1and1. Lately, I've been getting some errors. It says lost connection to mysql or mysql connection has gone away. It doesn't happen all the time but is quite annoying when it does. Is there anyway to fix it? Does it have something to do with server load?
Thanks in advance.
C-4 Hosting
01-23-2006, 08:14 PM
Some more specifics on what errors you are getting, what kind of script it is, and how to duplicate the problem would help us to let you know :)
ryanlwh
01-23-2006, 08:27 PM
thanks for replying. the error was this:
MySQL Error</b>: 2006 (MySQL server has gone away
This is a cronjob task that I run everyday at midnight. It ran correctly until the end of the script where the timestamp is inserted, and failed on this query. I had to perform the query manually. It happened once so far. However, this error happens a lot when I am using mysql in ssh, usually after running a few queries and sometimes even during queries, but it can reconnect itself in the mysql console. I've never had a mysql connection that goes away so quickly and has to reconnect almost every minute or two. I want to ensure that the connection would not go away when performing critical INSERT or UPDATE queries involving sign ups and payments. I know I can reconnect to the server everytime before a query but that seems to be inefficient. Any better solutions to this?
Database and slow webmail are the only issues I have with 1and1 so far. The rest looks great.
eWebtricity
01-23-2006, 10:28 PM
Your cronjob that you posted above doesn't really look like it does anything, is that really all that is in the cronjob or just part of it?
Is this all on the same server or is your app on one server and pointing to a MySQL db on another server? You might try running Jeremy Zawadony's mytop utility to watch for issues as well as the typical top utility for system resources. Maybe the whole system is taking a hit, could this be simple capacity issue?
ryanlwh
01-24-2006, 12:31 AM
The insert query is the last part of the cronjob. It has some select queries and loops before that. It's a newsletter script.
I'm on the business hosting plan and 1and1 provided me with an external mysql host: db246.perfora.net. I really think that this is the main issue of the lost connection. As far as mytop, I've tried downloading it but I couldn't install it as I'm not the root user. Looks like I'll need to write a statement to reconnect if I get this error code.
C-4 Hosting
01-24-2006, 10:03 AM
Your best bet is to find a way to do hosting that will have MySQL on the locahost! :)
Even if you fix this problem now, you will probably run into the same type of problems in the near future.
eWebtricity
01-24-2006, 10:29 AM
I think it's defintely a 1and1 issue then if your on the business hosting plan and they provided you an external db host. I would request a new MySQL host to hit as the one your using for lack of a better term "sucks". I think there is really only two possible causes, 1) the network congestion between the hosts is causing you to lose connection 2) the MySQL host is too busy to respond and you lose connection (i'm leaning heavy on this one). I would complain to 1and1
.....in my humble opinion of course.
ryanlwh
01-24-2006, 12:30 PM
Thanks for your replies.
C-4, if I knew beforehand that this plan gives me external host, I wouldn't have joined it.
eWeb, I guess the second explaination is closest to what I'm experiencing. Anyway, I think I'll try to create another mysql user and hopefully get a better connection, then transfer over. At the mean time I'm modifying the db class to reconnect when that error code is encountered...
Maybe upgrading to Developer is another solution?
vBulletin® v3.7.0 Beta 4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.