Page 1 of 1

Lost connection to MySQL server during query

Posted: Sun 16 Jan 2005 10:59
by leek
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

Connection pool?

Posted: Sun 16 Jan 2005 11:45
by leek
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

Re: Connection pool?

Posted: Mon 17 Jan 2005 14:46
by Oleg
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.

Thanks

Posted: Mon 17 Jan 2005 18:47
by leek
Thank you for your quick reply. I'll give it a try.