RE: Transaction context in use by another session
My guess is that you are dealing with mutithreaded problems, do you have any
static variables in your process?!
Else post you sample source, that will be helpfull :)
Cheers
"David Good" wrote:
> I've read MSDN cover to cover. I've searched the internet all the way to the
> end and even read the index, but I can not find a reasonable explanation for
> my issue.
>
> An C#/ASP.Net 1.1 application uses Enterprise Services for Transactional
> database updates. The object itself is marked
> [Transaction(TransactionOption.Required,Timeout=0),EventTrackingEnabled(true)] and each method is marked [AutoComplete(true)]
>
> A client is experiencing "Transaction context in use by another session"
> exceptions. The error logs show that the exception happens doing the same
> procedure, so it seems pretty cut and dry.
>
> However, we can't reproduce the error in our labs, on a development machine,
> or even on demand. The real problem is that the error occurs randomly. It's
> not reproducible. It may occur 20 times in one day and may not appear again
> for weeks.
>
> In order to recreate the conditions of the application, I created a test web
> app that references the same business layer objects that the primary
> application references, then hardcoded some values and used the same code to
> try to reproduce the error and test what I believe to be the issue. I am
> able to generate a "Transaction context in use by another session" exception,
> and I am able to pinpoint the line of code that causes it. A COM+
> Transaction is started, then several layers in the stack later a fetch is
> performed which is when the exception occurs. If I try it against SQL 2005 I
> get a similar, but more descriptive "DataReader" exception. Regardless, in
> both cases it's what I expect.
>
> So, after pinpointing the offensive line of code I still can't get the main
> application to fail. No matter what I try, how I configure COM+, IIS, or
> .Net, I can't get the main application to fail - only the test app.
>
> This has nothing to do with DTS, I've read the MSDN BUG: Error 3910,
> "Transaction Context in Use by Another Session" article, which has nothing at
> all to do with my scenario, other than the "In SQL Server, it is not
> permitted for two connections in the same transaction to execute a query
> against the same SQL instance concurrently." which would explain why my test
> app fails.
>
> But it doesn't explain why, when the test app and the real app are both
> using the exact same code, stepping through it line-by-line in VS2k3, and
> even running an SQL Profiler trace (with no differences except the failure),
> one fails and the other doesn't.
>
> This has to be something related to IIS or COM+ or both. I have even
> converted the code to WinForms and it fails reliably 100% of the time, yet
> the main web app doesn't. Again, same references, same code, same
> environment, same everything.
>
> I've been working on this problem for over a month and can not find a reason
> why it's so random.
>
> Has anyone experienced this or does anyone have any ideas why the
> "Transaction context in use by another session." would occur randomly
> (unrelated to DTS, or linked servers - just plain vanilla DTC and COM+)?
date: Thu, 6 Sep 2007 04:04:02 -0700
author: Troy