TransactionScope not working with a simple use case -bug?

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
HintonBR
Posts: 24
Joined: Mon 16 Jun 2008 17:07

TransactionScope not working with a simple use case -bug?

Post by HintonBR » Fri 23 Oct 2009 17:50

I have a very simple use case that is not working and I believe that it should. Either I am understanding something fundamentally wrong with TransactionScope (I have followed all the examples exactly) or this is a bug.

My model is a simple person table with one column FIRSTNAME. Below are two methods - one that using a Required TransactionScope and one that uses no TransactionScope. I can call each method by itself repeatedly, but as soon as I call the Required one and then call the No Transaction one I get an error
ORA-24776: cannot start a new transaction
when trying to call SaveChanges in the DoNoTransaction. The Stack trace is this

Devart.Data.Oracle.an.b(int A_0 = -1)
Devart.Data.Oracle.at.c(int A_0 = -1)
Devart.Data.Oracle.at.a(bool A_0 = false)
Devart.Data.Oracle.OracleInternalConnection.Commit()
Devart.Data.Oracle.OracleTransaction.Commit()
System.Data.EntityClient.EntityTransaction.Commit()
System.Data.Objects.ObjectContext.SaveChanges(System.Data.Objects.SaveOptions options = {unknown})



Code: Select all

 public void DoRequiredScope()
        {
            try
            {
                TransactionOptions transOptions = new TransactionOptions();
                transOptions.IsolationLevel = IsolationLevel.ReadCommitted;
                transOptions.Timeout = new TimeSpan(0, 0, 30);

                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transOptions))
                {
                    Debug.WriteLine("Current Transaction is " + Transaction.Current.TransactionInformation.LocalIdentifier);
                    Transaction.Current.TransactionCompleted += Current_TransactionCompleted;
                 

                    using (Entities entities = new Entities())
                    {
                        entities.Connection.Open();
                        PERSON app = entities.PERSON.First();
                        app.FIRSTNAME = "A Change w/txn";
                        Console.WriteLine(app.FIRSTNAME);
                        entities.SaveChanges();
                        entities.Connection.Close();
                        
                    }
                    ts.Complete();
                }
                    
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                //throw;
            }
        }

        public void DoNoTransaction()
        {
            try
            {
                using (Entities entities = new Entities())
                {
                    entities.Connection.Open();
                    PERSON app = entities.PERSON.First();
                    app.FIRSTNAME = "A Change w/o txn";
                    Console.WriteLine(app.FIRSTNAME);
                    entities.SaveChanges();
                    entities.Connection.Close();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }
I only added the call to explicitly open and close the connection when I saw a forum post about this possibly helping - the behavior of the code is the same without the explicit connection open/close.

Any help/explanation would be appreciated

Bryan
________
Last edited by HintonBR on Tue 15 Feb 2011 11:56, edited 1 time in total.

HintonBR
Posts: 24
Joined: Mon 16 Jun 2008 17:07

Using the latest release

Post by HintonBR » Fri 23 Oct 2009 17:52

I am experiencing this with the latest release of DevArt (October 19th) and I am using Oracle 10g
________
Last edited by HintonBR on Tue 15 Feb 2011 11:56, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 28 Oct 2009 14:11

I have tried to reproduce the problem and failed.
Maybe the problem is associated with the Current_TransactionCompleted method.
What operations are executed in it?

HintonBR
Posts: 24
Joined: Mon 16 Jun 2008 17:07

What version of Oracle Client are you using?

Post by HintonBR » Thu 29 Oct 2009 15:30

I commented out the event handler (it was just writing a debug statement) and still have the problem - are you using Oracle 10g or 11g? I am hearing from the other developers on my team that the behavior is different with 11g (I am seeing it on 10g). To repro I simply call a the Required method and then call the No transaction method.

Bryan
________
Last edited by HintonBR on Tue 15 Feb 2011 11:56, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 29 Oct 2009 15:40

I was using Oracle 10.2.0.1.0. What is the full version of your server?
Do you use Direct mode?

HintonBR
Posts: 24
Joined: Mon 16 Jun 2008 17:07

Post by HintonBR » Thu 29 Oct 2009 15:44

I am seeing this with Oracle XE (which is 10.2.0.1.0) which is the same as my client version. I am trying to run down what the other dev team was using - but I am pretty sure the server version is similar. I don't set explicitly set Direct mode - so I am using the default.
________
Last edited by HintonBR on Tue 15 Feb 2011 11:56, edited 1 time in total.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 02 Nov 2009 14:14

We are investigating the issue.
I will let you know about the results of our investigation.

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

Post by Shalex » Wed 04 Nov 2009 12:10

We have fixed the problem with consecutive usage of local and distributed transactions on the same connection with Oracle XE. Look forward to the next build of dotConnect for Oracle.

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

Post by Shalex » Fri 20 Nov 2009 16:29

dotConnect for Oracle v 5.35 is released.
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=16436.

HintonBR
Posts: 24
Joined: Mon 16 Jun 2008 17:07

Resolved

Post by HintonBR » Mon 23 Nov 2009 23:35

I downloaded the latest build and confirmed that I am no longer seeing the problem - thanks!!!
________

Post Reply