[Mono-devel-list] MySQL timeout

Rafael Teixeira monoman at gmail.com
Mon Feb 21 11:41:09 EST 2005


Well it sure looks like both mono and the mysql connector are doing
the right thing.
You is the one that is responsible for dealing with such conditions,
if needed, as your try/catches show that you understand how.

The problem is that you should be using the common ADO.NET idiom:

Open Connection
Execute Query
Read Data (if needed)
Close Connection

That way scales a lot better, even for Desktop Clients, as most
ADO.NET providers (connectors) implement connection pooling.

We should just determine if the connection pool manager of the mysql
connector, aside from killing unused connections after a timeout that
can alleviate your problem, has some checkConnectionLiveness feature
to avoid throwing that same exception in your face, when reusing a
connection...

HIH,

On Mon, 21 Feb 2005 17:02:14 +0100, Fabien Penso <penso at linuxfr.org> wrote:
> Hi !
> 
> I am trying to use the mysql connector MySql.Data.MySqlClient, and try
> to not crash when the mysld goes away.
> 
> The test program only does a select count(*), wait 10sec, goes
> again. The mysqld has a timeout value of 5 seconds (just to test) and
> here is what I get :
> 
> state of con: Open
> Connection unexpectedly terminated
> 
> Unhandled Exception: System.IO.IOException: Write failure ---> System.Net.Sockets.SocketException: The socket has been shut down
> in <0x00078> System.Net.Sockets.Socket:Send_nochecks (byte[],int,int,System.Net.Sockets.SocketFlags)
> in <0x000c3> System.Net.Sockets.Socket:Send (byte[],int,int,System.Net.Sockets.SocketFlags)
> in <0x000fb> System.Net.Sockets.NetworkStream:Write (byte[],int,int)
> --- End of inner exception stack trace ---
> 
> in <0x00152> System.Net.Sockets.NetworkStream:Write (byte[],int,int)
> in <0x0008f> System.IO.BufferedStream:Flush ()
> in <0x00182> MySql.Data.MySqlClient.PacketWriter:FlushBuffer ()
> in <0x000ed> MySql.Data.MySqlClient.PacketWriter:Flush ()
> in <0x000b8> MySql.Data.MySqlClient.NativeDriver:AuthenticateOld ()
> in <0x00075> MySql.Data.MySqlClient.NativeDriver:Authenticate ()
> in <0x00049> MySql.Data.MySqlClient.NativeDriver:Reset ()
> in <0x001e6> MySql.Data.MySqlClient.MySqlPool:GetPooledConnection ()
> in <0x0004e> MySql.Data.MySqlClient.MySqlPool:GetConnection ()
> in <0x00124> MySql.Data.MySqlClient.MySqlPoolManager:GetConnection (MySql.Data.MySqlClient.MySqlConnectionString)
> in <0x00071> MySql.Data.MySqlClient.MySqlConnection:Open ()
> 
> The piece of code is attached to this mail. Is there a way to see a
> mysqld has gone away and not crash ? I'm not so sure this is a problem
> with mono or the mysqld connector but any idea is welcome :)
> 
> 
> 
> 
> --
> Fabien Penso
> http://penso.info/
> 
> 
> 
> 


-- 
Rafael "Monoman" Teixeira
---------------------------------------
I'm trying to become a "Rosh Gadol" before my own eyes. 
See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.



More information about the Mono-devel-list mailing list