DeanBrisson / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

make connection per query problem in MySQL #147

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Issue #106 (2a94c2b2c85f2935dbc323b3d9a51df2c0913e22) is not work in MySQL.
https://code.google.com/p/dapper-dot-net/issues/detail?id=106

MySQL Connector's CancelQuery is very expensive.
Here is MySQL Connector's CancelQuery code

public void CancelQuery(int timeout)
{
    MySqlConnectionStringBuilder cb = new MySqlConnectionStringBuilder(
    Settings.ConnectionString);
    cb.Pooling = false;
    cb.AutoEnlist = false;
    cb.ConnectionTimeout = (uint)timeout;

    using (MySqlConnection c = new MySqlConnection(cb.ConnectionString))
    {
    c.isKillQueryConnection = true;
    c.Open();
    string commandText = "KILL QUERY " + ServerThread;
    MySqlCommand cmd = new MySqlCommand(commandText, c);
    cmd.CommandTimeout = timeout;
    cmd.ExecuteNonQuery();
    }
}

make a new connection(not connection pooling)
and execute "KILL QUERY" and close immediately.

If website is small, no problem.
But massive access, will be failed.
I encount many TIME_WAIT and application crashed.

This is very serious, if use Dapper and MySQL.

My hope is remove cmd.Cancel code.

Original issue reported on code.google.com by neu...@gmail.com on 17 Jul 2013 at 8:23