MySQL dotConnect Lockup/Infinite loop

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
ngoodwin
Posts: 9
Joined: Wed 29 Jul 2009 13:12

MySQL dotConnect Lockup/Infinite loop

Post by ngoodwin » Mon 11 Jan 2010 17:12

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);
            }
        }

ngoodwin
Posts: 9
Joined: Wed 29 Jul 2009 13:12

Reproducible in latest version

Post by ngoodwin » Tue 12 Jan 2010 13:47

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.

ngoodwin
Posts: 9
Joined: Wed 29 Jul 2009 13:12

Post by ngoodwin » Wed 13 Jan 2010 19:53

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.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 18 Jan 2010 10:44

We are investigating the issue. We will notify you about the results as soon as possible.

ngoodwin
Posts: 9
Joined: Wed 29 Jul 2009 13:12

Post by ngoodwin » Tue 19 Jan 2010 15:32

Do you guys have a timeframe? This is causing a critical issue here and we are really interested in a fix.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 20 Jan 2010 14:00

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.

ngoodwin
Posts: 9
Joined: Wed 29 Jul 2009 13:12

Post by ngoodwin » Wed 03 Feb 2010 19:13

Any update on the release of this?

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 04 Feb 2010 10:35

We plan to make a new build next week.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 09 Feb 2010 14:40

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.

ngoodwin
Posts: 9
Joined: Wed 29 Jul 2009 13:12

Post by ngoodwin » Tue 09 Feb 2010 17:07

Any idea when this will be released non-beta? We do not want to put the beta inside of our production release.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 09 Feb 2010 17:22

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.

Post Reply