List:Commits« Previous MessageNext Message »
From:rburnett Date:October 20 2008 10:52pm
Subject:Connector/NET commit: r1441 - in branches/5.1: . Driver/Source TestSuite/Source
View as plain text  
Modified:
   branches/5.1/CHANGES
   branches/5.1/Driver/Source/command.cs
   branches/5.1/TestSuite/Source/TimeoutAndCancel.cs
Log:
- fixed problem that caused in use connection strings to be modified when a pooled
connection timed out and was cancelled.  (bug #40091)  

The problem was that we were creating our connection object before setting the pooling
property to false.  This caused a connection to be made in an existing connection string
cache which caused all the connection strings in that cache to change when we set our
pooling property.  The fix was to create a connection string builder object, set the
pooling property, and then create the connection object.


Modified: branches/5.1/CHANGES
===================================================================
--- branches/5.1/CHANGES	2008-10-20 20:48:01 UTC (rev 1440)
+++ branches/5.1/CHANGES	2008-10-20 20:52:17 UTC (rev 1441)
@@ -3,6 +3,8 @@
     value doesn't come in as a server variable   
   - implemented Disposable pattern on MySqlTransaction class so including one in a using
statement
     and then not calling commit will cause a rollback when the using exits (bug #39817)
+  - fixed problem that caused in use connection strings to be modified when a pooled
connection
+    timed out and was cancelled.  (bug #40091)
 
 Version 5.1.7 - 8/20/08
  - Fixed problem with DDEX provider that could sometimes prevent table altering when
working with

Modified: branches/5.1/Driver/Source/command.cs
===================================================================
--- branches/5.1/Driver/Source/command.cs	2008-10-20 20:48:01 UTC (rev 1440)
+++ branches/5.1/Driver/Source/command.cs	2008-10-20 20:52:17 UTC (rev 1441)
@@ -239,9 +239,11 @@
 			if (!connection.driver.Version.isAtLeast(5, 0, 0))
 				throw new NotSupportedException(Resources.CancelNotSupported);
 
-			using(MySqlConnection c = new
MySqlConnection(connection.Settings.GetConnectionString(true)))
-			{
-                c.Settings.Pooling = false;
+            MySqlConnectionStringBuilder cb = new MySqlConnectionStringBuilder(
+                connection.Settings.GetConnectionString(true));
+            cb.Pooling = false;
+			using(MySqlConnection c = new MySqlConnection(cb.ConnectionString))
+            {
                 c.Open();
                 MySqlCommand cmd = new MySqlCommand(String.Format("KILL QUERY {0}",
                      connection.ServerThread), c);

Modified: branches/5.1/TestSuite/Source/TimeoutAndCancel.cs
===================================================================
--- branches/5.1/TestSuite/Source/TimeoutAndCancel.cs	2008-10-20 20:48:01 UTC (rev 1440)
+++ branches/5.1/TestSuite/Source/TimeoutAndCancel.cs	2008-10-20 20:52:17 UTC (rev 1441)
@@ -227,6 +227,36 @@
                 }
             }
             Assert.IsTrue(rows < 10000);
-        }        
+        }
+
+        /// <summary>
+        /// Bug #40091	mysql driver 5.2.3.0 connection pooling issue
+        /// </summary>
+        [Test]
+        public void ConnectionStringModifiedAfterCancel()
+        {
+            bool isPooling = pooling;
+            pooling = true;
+            string connStr = GetConnectionString(true);
+            pooling = isPooling;
+            connStr = connStr.Replace("persist security info=true", "persist security
info=false");
+
+            using (MySqlConnection c = new MySqlConnection(connStr))
+            {
+                c.Open();
+                string connStr1 = c.ConnectionString;
+
+                MySqlCommand cmd = new MySqlCommand("SELECT SLEEP(10)", c);
+                cmd.CommandTimeout = 5;
+
+                using (MySqlDataReader reader = cmd.ExecuteReader())
+                {
+                    string connStr2 = c.ConnectionString.ToLowerInvariant();
+                    Assert.AreEqual(-1, connStr2.IndexOf("pooling=true"));
+                    Assert.AreEqual(-1, connStr2.IndexOf("pooling=false"));
+                    reader.Read();
+                }
+            }
+        }
     }
 }

Thread
Connector/NET commit: r1441 - in branches/5.1: . Driver/Source TestSuite/Sourcerburnett20 Oct