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

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
bpipe
Posts: 19
Joined: Mon 08 Oct 2012 12:14

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

Post by bpipe » Mon 14 Apr 2014 12:06

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

bpipe
Posts: 19
Joined: Mon 08 Oct 2012 12:14

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

Post by bpipe » Mon 14 Apr 2014 12:18

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

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

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

Post by Pinturiccio » Wed 16 Apr 2014 11:52

We have reproduced the issue. We will investigate it and post here about the results as soon as possible.

Post Reply