CSLA and LINQ to SQL invokes Distributed Transaction Coordinator

CSLA and LINQ to SQL invokes Distributed Transaction Coordinator

Old forum URL: forums.lhotka.net/forums/t/9463.aspx

jmcphers posted on Wednesday, September 01, 2010

I am trying to use CSLA with LINQ to SQL as data access mechanism.  Most things have gone well until recently when I started getting an error.  When updating a child record, I receive the following error message:

System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed.

I am modeling my code off of the ProjectTracker sample that uses LINQ as the DAL.  I establish the context with code similar to the following:

            using (var ctx = ContextManager<DAL.PetshopDataContext>.GetManager("PetShopConnectionString"))

From what I understand the MSDTC is most likely getting invoked because a second connection is being opened somewhere but I cannot seem to locate where this may be occurring. My application only accesses one database at this time. If any one has any ideas where I may want to look to correct this issue I would greatly appreciate the help.

I can provide more detail or upload the app if necessary.

RockfordLhotka replied on Wednesday, September 01, 2010

Using ContextManager is a good start. There are some things to consider:


jfreeman replied on Thursday, March 03, 2011

I have an application where I am getting a lot of timeouts from users and we think it has to do with ContextManager.   We generally have anywhere from 10 - 15 users in one particular screen.  They are all updating different records on the database.  When I do a DB call, I use the following code to create the ContextManager:


using (var mgr = ContextManager<CensusDataContext>.GetManager("HotelDB")) { 

//  DB Code


Based on what I see in the CSLA code, it looks like every users would be using the same ContextManager to do database calls.  Is that correct?  Our theory is that if one user has a long running query and gets a timeout then any other users who is doing a DB call at the time is getting an error too since they are using the same ContextManager.  Is this true?  If so,  what is the best way to handle the ContextManager in these type of scenarios?  Thanks for your help.


ajj3085 replied on Thursday, March 03, 2011

No, users would not be sharing the same ContextManager.  The CM stores the managed object in HttpContext.Items, which is unique for each request.

JonnyBee replied on Friday, March 04, 2011

Use the SqlProfiler to see the actual sql querys and you will also see that the have different ClientProcessID's and SPIDs.

You are most likely experiencing deadlock and/or missing indexes (resulting in full scan of tables).

Copyright (c) Marimer LLC