I've never had a lot of luck tracking down this sort of problem. One
thing I've found to be a good first step is to add each server
involved to the other server's /etc/hosts file (and restart MySQL so
it notices).
Don't have much more to offer other than the usual suspects: recent
versions, persistent vs. non-persistent connections, etc. A long shot
would be to make sure your always talking to the same database server-
if you're doing, say, DNS round-robin or load balancing or something,
maybe you're getting shunted to a different db server and it's killing
the connection... don't know what your setup is. Another long shot in
a multi-db-server config would be to make sure they all have different
server ID's.
Good luck... hopefully someone else has better advice :)
Jake
On Wed, Oct 29, 2008 at 2:47 AM, Waynn Lue <waynnlue@stripped> wrote:
> We've started seeing mysql errors in the logs, and when i look at the output
> of mysql_error() (in php), i get "lost connection to mysql server during
> query". Here's an example stack trace:
>
> 'Can't connect to <name> database [Lost connection to MySQL server during
> query]'
>
> Similarly, we're seeing stack traces here as well:
>
> 'Can't connect to <name> database []'
>
> I usually only see this mesasge when I don't use a connection for awhile and
> it timeouts, but in this case, the connection is only opened for the
> duration of a script, which can't be running for more than a second. The
> mysql error logs don't show anything, and wait_timeout is set to 28800.
>
> At first, I thought it was because I was calling mysql_select_db too much,
> so I ended up using two mysql connections per page load, but that didn't
> seem to change anything. How can we prevent this error from happening, what
> else can I do to diagnose this further? Google brings up some more
> discussions about it, but nothing seems related to this, like packetsize.
> This is happening when we select two ids from a database. And SHOW
> PROCESSLIST shows that the number of connections aren't even coming close to
> max connections.
>
> Thanks for any advice,
> Waynn
>