Page 1 of 1

BUG: DependentTransaction, incorrect thread synchronization results in db serialization exception

Posted: Mon 14 Apr 2014 12:06
by bpipe

Code: Select all

        [TestMethod]
        public void TestUpdate()
        {
            for (int i = 0; i < 1000; i++)
            {
                using (TransactionScope tx = new TransactionScope())
                {
                    DependentTransaction depTx = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
                    System.Threading.Tasks.Task.Factory.StartNew(() =>
                                                                     {
                                                                         Thread.Sleep(100);
                                                                         depTx.Complete();
                                                                     });
//var connection = CreateConnection(); //pseudo code
// connection.Update("UPDATE test SET value='bar' WHERE key='foo'"); //pseudo code
                    tx.Complete();
                }
            }
        }

Re: BUG: DependentTransaction, incorrect thread synchronization results in db serialization exception

Posted: Mon 14 Apr 2014 12:18
by bpipe
As a workaround you can use your own thread sync methods, like:

Code: Select all

        [TestMethod]
        public void TestUpdate()
        {
            for (int i = 0; i < 1000; i++)
            {
                using (TransactionScope tx = new TransactionScope())
                {
                    DependentTransaction depTx = Transaction.Current.DependentClone(DependentCloneOption.RollbackIfNotComplete);
                    var t = System.Threading.Tasks.Task.Factory.StartNew(() =>
                                                                     {
                                                                         Thread.Sleep(100);
                                                                         depTx.Complete();
                                                                     });
// Do SQL Update here
                    t.Wait();
                    tx.Complete();
                }
            }
        }

Re: BUG: DependentTransaction, incorrect thread synchronization results in db serialization exception

Posted: Wed 16 Apr 2014 11:52
by Pinturiccio
We have reproduced the issue. We will investigate it and post here about the results as soon as possible.