The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Transaction Question

Last post 12-20-2007, 7:59 AM by scotthuynh. 5 replies.
Sort Posts: Previous Next
  •  12-18-2007, 5:33 AM 7245

    Transaction Question

    Hi,

    I'm currently using SQL Server 2000 with Entityspace 1.5.3.  There seems to be a connection leak everytime a rollback is executed. For example with the following code

    Private Sub test()

    Dim Jobs_Rec As New Jobs

    Jobs_Rec.AddNew()

    Dim scope As esTransactionScope = New esTransactionScope

    Try

    Using scope

    Jobs_Rec.SJobName = "New Job"

    Jobs_Rec.Save()

    'scope.Complete()

    Throw New Exception("error")

    End Using

    Catch

    'do someting

    Finally

    CType(scope, IDisposable).Dispose()

    End Try

    End Sub

    If I don't do a scope.complete and try to process another transaction, it will create a new connection to the database. I thought it was suppose to rollback the current connection and re-use that old connection for the new transaction. Any help is appreciated. Thanks.

  •  12-18-2007, 9:06 AM 7251 in reply to 7245

    Re: Connection Leak

    There has never been a connection leak in EntitySpaces that we know of. We have however worked around a bug in Microsofts SqlTransaction class since 1.5.3. We always create new connections, we never hang onto and use existing ones (connection pooling handles that). However, during a transaction of course we do make sure a single connection is in use.  EntitySpaces has improved light years over 1.5.3 and I would encourage you to consider upgrading at some point.

     

    PS: I am going to change the title of this thread ... 


    EntitySpaces | Twitter | BLOG
  •  12-19-2007, 7:13 PM 7282 in reply to 7251

    Re: Connection Leak

    Thanks for your reply. I did download the new version and now I'm having a concurrency problem.  Using the same code as before, I tried to update the same record from two different machine and I'm not getting a concurrency exception.

     The table is pretty simple, just 3 fields. An identity field, name, and a rowversion field defined as timestamp. The two updates seem to be clobbering one over the other. Please let me know what I need to do. Thanks.

     

     

     

  •  12-19-2007, 7:43 PM 7284 in reply to 7282

    Re: Connection Leak

    Didn't you run into a bunch of breaking issues? We made some significant changes since 1.5.3?

    Try this on one machine ...

     

    Code:
    Employees emp1 = new Employees();
    emp1.LoadByPrimaryKey(1);

    Employees emp2 = new Employees();
    emp2.LoadByPrimaryKey(1);

    emp1.FirstName = "Wow1";
    emp2.FirstName = "Wow2";

    emp1.Save();
    emp2.Save();

    You should get the concurrency error when emp2.Save() is called since we read them both at the same time ...  If you don't please post your CREATE TABLE statement for the table in question, we have unit tests in our system that verify that this works.  Your column type should be "timestamp".

    EntitySpaces | Twitter | BLOG
  •  12-20-2007, 5:56 AM 7286 in reply to 7284

    Re: Connection Leak

    Any luck?

    EntitySpaces | Twitter | BLOG
  •  12-20-2007, 7:59 AM 7288 in reply to 7286

    Re: Connection Leak

    I tried that, but what I was doing wrong was trying to catch a generic Exception not esConcurrencyException.

    Thanks for your help.

    Scott...

View as RSS news feed in XML