Lost connection to MySQL server during query

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
leek
Posts: 8
Joined: Sun 16 Jan 2005 10:51

Lost connection to MySQL server during query

Post by leek » Sun 16 Jan 2005 10:59

Hi there

I'm developing a web app using mysql 4.1 and corelab 2.7, .NET framework 1.1.

I use components (effectively) that maintain connections to the database. The connections are religiously closed.

Whenever the mysql server is restarted (by choice or accident), and the ASP process is not, the following exception is thrown:
Lost connection to MySQL server during query.

I've tried catching the exception, disposing the connection, reinstantiating, etc., but the only solution seems to be restarting the asp process (not ideal).

Any solutions?

Thanks in advance
Ben

leek
Posts: 8
Joined: Sun 16 Jan 2005 10:51

Connection pool?

Post by leek » Sun 16 Jan 2005 11:45

I've just been reading older posts, trying to get ideas.

Does the above error result from the connection pool?

Should I drain the pool on reception of this exception. or disable pooling to begin with? Once the pool has been drained do I need to dispose/reinstantiate etc.?

Again, thanks in advance.
Ben

Oleg
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: Connection pool?

Post by Oleg » Mon 17 Jan 2005 14:46

Yes, this behaviour is related with the connection pool.
You shouldn't disable connection pooling as performance of your
ASP application can fall. When mysql server is restarted you should
wait for a while up to 5 minutes during which connection pool will remove
all connections itself. You can call MySqlConnection.ClearPool or
MySqlConnection.ClearAllPools for explicit release connections in the pool.
These methods don't release connections at once, they can release all
connections during some time in about 30 seconds.

leek
Posts: 8
Joined: Sun 16 Jan 2005 10:51

Thanks

Post by leek » Mon 17 Jan 2005 18:47

Thank you for your quick reply. I'll give it a try.

Post Reply