MySql.Data connection pool bug

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
7/14/2010 12:56:21 PM
Gravatar
Total Posts 2

MySql.Data connection pool bug

Hi joe, 

i've found a giant problem on MySql.Data.dll. Check this:

public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
{
    MySqlDataReader reader;
    MySqlConnection connection = new MySqlConnection(connectionString);
    connection.Open();
    try
    {
        reader = ExecuteReader(connection, null, commandText, commandParameters, false);
    }
    catch
    {
        connection.Close();
        throw;
    }
    return reader;
}

...so, in this way the connection.Close() method will never call. How can I fix it? There's somewhere this source code to compile? I've a problem with the size of the mysql connection pool. At every call to this method a new "zombie" process is appened to mysql process...

(basically i just need to use  IDataReader GetUserList(int siteId) method...)

Cheers.

L
 

7/14/2010 1:06:13 PM
Gravatar
Total Posts 18439

Re: MySql.Data connection pool bug

Hi,

First, please do not post bug reports about your own code in the mojoPortal bug forum. The code you posted does not exist in mojoportal and this is in no way a mojoportal bug nor is it a bug in MySql.Data.dll. It is a mistake in your own code and your own misunderstanding that causes the connections to be left open  and this exhausts your connection pool.

If you post your question in the developer forum, I will explain what you are doing wrong.

Best,

Joe

7/14/2010 1:31:58 PM
Gravatar
Total Posts 18439

Re: MySql.Data connection pool bug

What you need to understand is that a DataReader is a live connection to the database, the connection must remain open while you use the reader. The method in the MySql.Data.dll only tries to close the connection if an error happens, it is up to you to close the connection when you are finished with the DataReader to prevent leaking connections from the connection pool. If they closed the connection in that method the reader would not work because a DataReader needs a live connection while reading the data. It is a fast forward only cursor through the data.

Best way to do that is

using(IDataReader reader = SomeMethodThatGetsADataReader())
{

while (reader.Read())
{

//use the data 

}

}

by using the using statement it will close the reader even if an error happens.

If Databinding to a UI control you don't need the while(reader.Read()) because .DataBind() will do that for you, but all use of the reader should be inside the using statement

Hope it helps,

Joe

 

7/14/2010 2:17:13 PM
Gravatar
Total Posts 2

Re: MySql.Data connection pool bug

I'm sorrow,absolutly my fault. Thanks a lot for YouR time, you save me! I 'll buy you a beer. Thanks again. L
You must sign in to post in the forums. This thread is closed to new posts.