| Bug #28637 | Pooled connections are corrupted | ||
|---|---|---|---|
| Submitted: | 23 May 2007 23:09 | Modified: | 16 Aug 2007 7:50 |
| Reporter: | Nick dAlterio | Email Updates: | |
| Status: | No Feedback | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | 5.0.7, 5.1.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | ADO.NET, DataReader, pooling | ||
[25 May 2007 17:52]
Nick dAlterio
Updated severity to correct value
[12 Jul 2007 18:01]
Tonci Grgin
Thanks for your report Nick and sorry, I completely missed it.
[16 Jul 2007 7:50]
Tonci Grgin
Nick, can you please post complete test case together with DDL statements. Also, I don't see any cleanup code in your sample.
Example:
MySqlConnection conn = new MySqlConnection();
conn.ConnectionString = "DataSource=localhost;...";
conn.Open();
MySqlCommand cmdCreateTable = new MySqlCommand("DROP PROCEDURE IF EXISTS `test`.`SP_BUG28637`", conn);
cmdCreateTable.CommandType = CommandType.Text;
cmdCreateTable.CommandTimeout = 0;
cmdCreateTable.ExecuteNonQuery();
cmdCreateTable.CommandText = "DROP TABLE IF EXISTS `test`.`bug28637`";
cmdCreateTable.ExecuteNonQuery();
cmdCreateTable.CommandText = "CREATE TABLE `test`.`bug28637` (" +
--<cut>--
" ) ENGINE=MyISAM";
cmdCreateTable.ExecuteNonQuery();
cmdCreateTable.CommandText = ("CREATE PROCEDURE `test`.`SP_BUG28637`(" + "\n" +
--<cut>--
") \n" +
"BEGIN INSERT INTO bug28637 (`ID`, NAME) VALUES (P_ID, P_NAME); END\n");
etc...
[16 Aug 2007 23:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".

Description: The following code segment is triggered by a button press in a dialog. The first time the button is pressed it works perfectly. The second time it is pressed I get an IndexOutOfRangeException exception when I call recdr.GetOrdinal("ColName"). The column exists in the data base and was retrieved successfully in the first run. Looking at the Connection object I noticed, hadBeenOpen = true so it seems like a pooled connection has been used for the second run. I then tried turning off connection pooling via the connection string and it works every time ! This workaround is obviously not an ideal solution to the problem It appears that the connection pooling functionality is broken in this case How to repeat: Run this more than once using ( MySqlConnection con = new MySqlConnection( "..." ) ) { try { con.Open(); using (MySqlCommand reccmd = new MySqlCommand("sp_GetAnswers", con)) { reccmd.CommandType = CommandType.StoredProcedure; MySqlParameter custidpar = new MySqlParameter("custid", MySqlDbType.String); custidpar.Direction = ParameterDirection.Input; custidpar.Value = custid; reccmd.Parameters.Add(custidpar); using (MySqlDataReader recdr = reccmd.ExecuteReader()) { if (recdr.Read()) { recdr.GetOrdinal("ColName"); /// BANG } } } } catch (MySqlException dbe) { MessageBox.Show(dbe.Message); } catch (Exception e) { MessageBox.Show(e.Message); } } Suggested fix: Disable connection pooling