HighTechTalks DotNet Forums  

Transaction context in use by another session

Dotnet Distributed Applications microsoft.public.dotnet.distributed_apps


Discuss Transaction context in use by another session in the Dotnet Distributed Applications forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?RGF2aWQgR29vZA==?=
 
Posts: n/a

Default Transaction context in use by another session - 07-11-2007 , 05:16 PM






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+)?

Reply With Quote
  #2  
Old   
=?Utf-8?B?VHJveQ==?=
 
Posts: n/a

Default RE: Transaction context in use by another session - 09-06-2007 , 07:04 AM






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:

Quote:
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+)?

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.