Page 1 of 1

MySQL dotConnect Lockup/Infinite loop

Posted: Mon 11 Jan 2010 17:12
by ngoodwin
The following code sample creates what seems to be a recursive infinite loop. I suspect that when the connection exception occurs, it tries to close the connection and thus will tries to commit the open transaction, which fails and tries to close the connection, etc.

This happens on version 5.40.44.0. Can you please check if this is fixed in the current newest version? If so i will simply upgrade, however I'd like to avoid the upgrade process if the current version is fixed and just simply wait till a version with this bug fixed is released. Thank you.

Code: Select all

/// 
        /// Reproduce locked table bug for DevART MySQL
        /// 
        private void BugRepro()
        {
            try
            {
                var connectionStringBuilder = new MySqlConnectionStringBuilder
                                              {
                                                      Host = "*", 
                                                      UserId = "*", 
                                                      Password = "*"
                                              };
                string cs = connectionStringBuilder.ToString();
                string dataBaseName = "devartBugRepro";
                string tableName = "testTable";
                string setupSchema = "CREATE DATABASE `" + dataBaseName
                                     +
                                     @"`;
                    CREATE TABLE  `"
                                     + dataBaseName + "`.`" + tableName
                                     +
                                     @"` (
                      `Id` int(11) NOT NULL auto_increment,
                      `Name` varchar(45) default NULL,
                      PRIMARY KEY  (`Id`)
                    ) ENGINE=InnoDB;";
                string dropSchema = "DROP DATABASE `" + dataBaseName + "`";
                using (var mysqlConn = new MySqlConnection(cs))
                {
                    mysqlConn.Open();
                    using (MySqlCommand cmd = mysqlConn.CreateCommand())
                    {
                        cmd.CommandText = setupSchema;
                        cmd.ExecuteNonQuery();
                        var endSignal = new ManualResetEvent(false);
                        var readySignal = new ManualResetEvent(false);
                        var lockThread =
                                new Thread(
                                        x =>
                                        this.LockDB(endSignal, 
                                                    readySignal, 
                                                    cs, 
                                                    dataBaseName, 
                                                    tableName));
                        lockThread.Start(); 
                        readySignal.WaitOne(); // Wait for thread to signal us to go.
                        cmd.CommandText = "USE " + dataBaseName;
                        cmd.ExecuteNonQuery();
                        using (var itx = mysqlConn.BeginTransaction())
                        {
                            using (var transCmd = mysqlConn.CreateCommand())
                            {
                                transCmd.Transaction = itx;
                                transCmd.CommandText = "INSERT INTO `" + tableName
                                                  +
                                                  "`  (`Id`, `Name`) VALUES (NULL, \"Nick\");";
                                transCmd.ExecuteNonQuery();
                                itx.Commit();
                            }
                        }

                        endSignal.Set();
                        cmd.CommandText = dropSchema;
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in BugRepro: " + ex);
            }
        }

        /// 
        /// Locks the DB.
        /// 
        /// 
        /// The  to end this thread.
        /// 
        /// 
        /// Signal we have locked the table and are finished.
        /// 
        /// 
        /// The connection string.
        /// 
        /// 
        /// Name of the database.
        /// 
        /// 
        /// Name of the table.
        /// 
        private void LockDB(WaitHandle endSignal, 
                            WaitHandle readySignal, 
                            string connectionString, 
                            string dataBaseName, 
                            string tableName)
        {
            try
            {
                using (var mysqlConn = new MySqlConnection(connectionString))
                {
                    mysqlConn.Open();
                    using (MySqlCommand cmd = mysqlConn.CreateCommand())
                    {
                        cmd.CommandText = "USE " + dataBaseName;
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "LOCK TABLE " + tableName + " WRITE";
                        cmd.ExecuteNonQuery();
                        WaitHandle.SignalAndWait(readySignal, endSignal);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in LockDB Thread: " + ex);
            }
        }

Reproducible in latest version

Posted: Tue 12 Jan 2010 13:47
by ngoodwin
I have just used the same code sample as above to reproduce this bug in MySql DotConnection version 5.50.62.0. I really need a response soon, this bug is critical. I can't see a way to work around this without this problem being resolved.

Posted: Wed 13 Jan 2010 19:53
by ngoodwin
I'd really like a reply here. I emailed you guys too and have not heard anything back. Would love to know if this will be fixed or not. This is a huge issue.

Posted: Mon 18 Jan 2010 10:44
by Shalex
We are investigating the issue. We will notify you about the results as soon as possible.

Posted: Tue 19 Jan 2010 15:32
by ngoodwin
Do you guys have a timeframe? This is causing a critical issue here and we are really interested in a fix.

Posted: Wed 20 Jan 2010 14:00
by StanislavK
We have fixed the issue. The fix will be available in the nearest build. We plan to release it in the end of the month.

To receive the build before it is released, please contact us:
http://www.devart.com/company/contact.html
If you have an active license, please specify its number. Otherwise, we can send you the trial edition.

Posted: Wed 03 Feb 2010 19:13
by ngoodwin
Any update on the release of this?

Posted: Thu 04 Feb 2010 10:35
by Shalex
We plan to make a new build next week.

Posted: Tue 09 Feb 2010 14:40
by StanislavK
The new 5.70.90 Beta build of dotConnect for MySQL is available for download now. It can be downloaded from
http://www.devart.com/dotconnect/mysql/download.html
(trial version) or from Registered Users' Area (for users with active subscription only). For more information, please refer to
http://www.devart.com/forums/viewtopic.php?t=17059.

Posted: Tue 09 Feb 2010 17:07
by ngoodwin
Any idea when this will be released non-beta? We do not want to put the beta inside of our production release.

Posted: Tue 09 Feb 2010 17:22
by StanislavK
The build is called Beta because it includes major changes intended to support Entity Framework v4 Beta 2. These changes mostly concern the Devart Entity Developer application. dotConnect for MySQL itself is stable.