• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Lost connection to MySQL server during query

Mark R

Diamond Member
I've been developing a few simple scripts in ASP.NET which connect to a mySQL database.

Every now and again (probably every 20 queries or so) a query will fail with this error, and it isn't clear why. Pretty much any query can fail, but all work most of the time.

It's managed hosting and I don't know enough about MySQL to change anything from the defaults. The database is really just a test database with a few tens of rows, and no BLOBs.

I've developed a major project with ASP.NET and MS-SQL before, and have never run into a remotely similar problem. So I think it's unlikely that it's my code.

I'd be very grateful for any help or advice on how to tame MySQL (or chnage provider if it looks like a host problem).

This is an example of the code that will fail randomly:


 
Originally posted by: Mark R
Every now and again (probably every 20 queries or so) a query will fail with this error, and it isn't clear why.
No kidding. What's 'this error'? 😛 (Chained exceptions too please).

Is it possible that your host is just flaky? It could be the mysql server, it could be the odbc pipe... Do you test this in isolation on your own machine at all?
 
The error is that in the thread title.

It's System.Data.Odbc.OdbcException 'ERROR [HY000] [MySQL][ODBC 3.51 Driver][mysqld-4.0.27-max-log] Lost connection to MySQL server during query'.

There are no inner exceptions - the error occurs on the line where the command is executed (whether it is an executescalar, executereader, executenonquery, or a data adapter operation). Any and all of these methods of running a query can and do fail randomly with the same error.

I've thoroughly tested it on a local machine, although using Access or SQL express databases - and the queries work perfectly, even with multiple simultaneous connections, etc.

 
Well, I'd definitely try it with mysql on your own machine. Same version, same driver, same asp.net... After that, I'd be talking to the host. Any idea how many people are connecting to the same database? Maybe it's just overloaded.

When you're reporting an error, it's usually nice to include the entire stack trace. A line saying "Lost connection..." doesn't communicate very much.
 
Thanks. I'm guessing it's probably a host problem - I don't know how many people are sharing the same mysql server, but I suspect it's a lot. It's budget hosting, so it wouldn't surprise me if it's been significantly oversold.

I'll try it with MySQL locally, and see how it goes.

Anyway, thanks for the advice.
 
Back
Top