PDA

View Full Version : TxScopeTransactionManager - problems with nested transactions



Kanakaraju
07-03-2007, 03:11 PM
Hi,

I am using TxScopeTransactionManager for transaction handling and using method level transactions by placing the [Transaction()] attribute on the service methods.

I am getting errors when I have nested transactions. If a method that is in a transaction scope (by having the Transaction attribute) invokes another method that is also in the transaction scope, the second method is throwing an error or exception. If I delete the transaction attribute on either of the methods, then they are working fine.

I am getting the following exception Trace:

-------------
Transaction manager [TxScopeTransactionManager] does not support transaction suspension

Spring.Transaction.TransactionSuspensionNotSupport edException was unhandled by user code
Message="Transaction manager [TxScopeTransactionManager] does not support transaction suspension"
Source="Spring.Data"
StackTrace:
at Spring.Transaction.Support.AbstractPlatformTransac tionManager.DoResume(Object transaction, Object

suspendedResources)
at Spring.Transaction.Support.AbstractPlatformTransac tionManager.resume(Object transaction, Object

suspendedResources)
at

Spring.Transaction.Support.AbstractPlatformTransac tionManager.cleanupAfterCompletion(DefaultTransact ionStatus

status)
at Spring.Transaction.Support.AbstractPlatformTransac tionManager.ProcessCommit(DefaultTransactionStatus

status)
at Spring.Transaction.Support.AbstractPlatformTransac tionManager.Commit(ITransactionStatus

transactionStatus)
at

Spring.Transaction.Interceptor.TransactionAspectSu pport.DoCommitTransactionAfterReturning(Transactio nInfo

transactionInfo)
at Spring.Transaction.Interceptor.TransactionIntercep tor.Invoke(IMethodInvocation invocation)
at Spring.Aop.Framework.AbstractMethodInvocation.Proc eed()
at Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Inv oke(Object proxy, Object target, Type targetType,

MethodInfo targetMethod, Object[] args, IList interceptors)
at CompositionAopProxy_87a4828668fa492a81721c24177d2b d0.FindByName(String username)
at AcmeBank.Server.Service.AuthenticationService.Auth enticate(String username, String password) in

D:\Spring\Apps\Reference-Implementation-2\AcmeBank\AcmeBank.Server\Service\AuthenticationS ervice.cs:line 25
at Spring.DynamicReflection.Method_Authenticate_d8d33 074625d4ac3b4c0d420ebe1d329.Invoke(Object target,

Object[] args)
at Spring.Util.DynamicReflection.SafeMethod.Invoke(Ob ject target, Object[] arguments)
at Spring.Aop.Framework.ReflectiveMethodInvocation.In vokeJoinpoint()
at Spring.Aop.Framework.AbstractMethodInvocation.Proc eed()
at Spring.Transaction.Interceptor.TransactionIntercep tor.Invoke(IMethodInvocation invocation)
------------------

Has anyone faced a similar issue? Any help figuring out how I can handle this issue is highly appreciated.

Thanks
Kanakaraju

Mark Pollack
07-03-2007, 04:05 PM
Hi Kanakaraju,
I've heard of this coming up recently, I'm investigating now and will post back once I have a handle on the issue.
Cheers,
Mark

Mark Pollack
07-03-2007, 11:34 PM
Hi Kanakaraju,

There was a bug in the implementation of TxScopeTransactionManager's IsExistingTransaction method that is now fixed. You can get the latest download with the changes.

Cheers,
Mark

Kanakaraju
07-04-2007, 01:49 PM
Thanks Mark.

I downloaded the latest nightly build namely "Spring.NET-20070702-2220.zip" and tried to use the DLLs from there in my projects. When I reference the new DLLs from the above, I am getting all kinds of DLL incompatibility errors. I could not even instantiate the application context. Is this a stable version and is this the version in which the TxScopeTransactionManager issue was fixed? Or am I looking at the wrong version?

I am using Visual Studio 2005 with .Net framework 2.0. And I an referencing the Dlls in the /bin/net/2.0/debug folder. Is this from where should I reference? Can you please provide me the details?

Thank you very much.

Kanakaraju

Mark Pollack
07-04-2007, 08:48 PM
Hi,
The file Spring.NET-20070702-2220.zip, doens't contiain the fix, it would have been dated the with the 3rd in the date. The latest didn't build due a small error, which I've fixed and kicked off a new build on the cruise control site. I'll ping back once I see that it has finished and the download is usable. I've never had a corrupt build before from that machine so something might be amiss. Thanks for your patience.
Cheers,
Mark

Kanakaraju
07-05-2007, 04:57 AM
Hi Mark,

Sorry for bugging you. it seems the latest build on the cruise control site has failed. Please let me know when you have a successful build of the latest version with the TxScopeTrasactionManager nested transactions fix. I am looking at http://ciweb.codestreet.com:88/ccnet/default.aspx?_action_ViewFarmReport=true

Thanks for your support. I appreciate your help.

Kanakaraju

Mark Pollack
07-05-2007, 09:31 PM
Hi,
You can download this version

http://www.springframework.net/downloads/nightly/Spring.NET-20070705-1328.zip

I tried it out the and it worked fine. Sorry for the delay.

Mark

Kanakaraju
07-07-2007, 11:06 AM
Mark,

Sorry to be of constant trouble. But the nested transaction problem still persists even after using the new DLLs downloaded from the location you mentioned. Again the same thing. With out nesting the transactions, there was no problem, but with nesting I am getting the following exceptions:

IlligaelTransactionStateException

Participating in existing transactions is not supported - when 'IsExistingTransaction' returns true, appropriate 'DoSetRollbackOnly' behavior must be provided

Trace:

Spring.Transaction.IllegalTransactionStateExceptio n was unhandled
Message="Participating in existing transactions is not supported - when 'IsExistingTransaction' returns true, appropriate 'DoSetRollbackOnly' behavior must be provided"
Source="Spring.Data"
StackTrace:
at Spring.Transaction.Interceptor.TransactionAspectSu pport.DoCloseTransactionAfterThrowing(TransactionI nfo transactionInfo, Exception exception) in c:\projects\daily\Spring.Net\src\Spring\Spring.Dat a\Transaction\Interceptor\TransactionAspectSupport .cs:line 426
at Spring.Transaction.Interceptor.TransactionIntercep tor.Invoke(IMethodInvocation invocation) in c:\projects\daily\Spring.Net\src\Spring\Spring.Dat a\Transaction\Interceptor\TransactionInterceptor.c s:line 78
at Spring.Aop.Framework.AbstractMethodInvocation.Proc eed() in c:\projects\daily\Spring.Net\src\Spring\Spring.Aop \Aop\Framework\AbstractMethodInvocation.cs:line 283
at Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Inv oke(Object proxy, Object target, Type targetType, MethodInfo targetMethod, Object[] args, IList interceptors) in c:\projects\daily\Spring.Net\src\Spring\Spring.Aop \Aop\Framework\DynamicProxy\AdvisedProxy.cs:line 185
at CompositionAopProxy_256298c795ba4bd799b168fa4ae416 59.GetAccountsByUserID(User user)
at AcmeBank.Server.Service.AuthenticationService.Auth enticate(String username, String password) in D:\Spring\Apps\Reference-Implementation-4\AcmeBank_Tx_2\AcmeBank.Server\Service\Authentica tionService.cs:line 58
at Spring.DynamicReflection.Method_Authenticate_2c3cd 83b5a914a9a89dd71ddf62a9cf5.Invoke(Object target, Object[] args)
at Spring.Util.DynamicReflection.SafeMethod.Invoke(Ob ject target, Object[] arguments) in c:\projects\daily\Spring.Net\src\Spring\Spring.Cor e\Util\DynamicReflection\DynamicMethod.cs:line 108
at Spring.Aop.Framework.ReflectiveMethodInvocation.In vokeJoinpoint() in c:\projects\daily\Spring.Net\src\Spring\Spring.Aop \Aop\Framework\ReflectiveMethodInvocation.cs:line 90
at Spring.Aop.Framework.AbstractMethodInvocation.Proc eed() in c:\projects\daily\Spring.Net\src\Spring\Spring.Aop \Aop\Framework\AbstractMethodInvocation.cs:line 260
at Spring.Transaction.Interceptor.TransactionIntercep tor.Invoke(IMethodInvocation invocation) in c:\projects\daily\Spring.Net\src\Spring\Spring.Dat a\Transaction\Interceptor\TransactionInterceptor.c s:line 79
at Spring.Aop.Framework.AbstractMethodInvocation.Proc eed() in c:\projects\daily\Spring.Net\src\Spring\Spring.Aop \Aop\Framework\AbstractMethodInvocation.cs:line 283
at Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Inv oke(Object proxy, Object target, Type targetType, MethodInfo targetMethod, Object[] args, IList interceptors) in c:\projects\daily\Spring.Net\src\Spring\Spring.Aop \Aop\Framework\DynamicProxy\AdvisedProxy.cs:line 185
at CompositionAopProxy_0ff0b7301a944bcba565b4551e97a7 f9.Authenticate(String username, String password)
at AcmeBank.Server.Messaging.Processors.Authenticatio nRequestProcessor.HandleMessage(Message message) in D:\Spring\Apps\Reference-Implementation-4\AcmeBank_Tx_2\AcmeBank.Server\Messaging\Processo rs\AuthenticationRequestProcessor.cs:line 41
at AcmeBank.Core.Messaging.MessageListenerAdapter.Pro cessMessage(Message message) in D:\Spring\Apps\Reference-Implementation-4\AcmeBank_Tx_2\AcmeBank.Core\Messaging\MessageLis tenerAdapter.cs:line 66
at AcmeBank.Core.Messaging.MessageListenerContainer.D ispatchListener(Object state) in D:\Spring\Apps\Reference-Implementation-4\AcmeBank_Tx_2\AcmeBank.Core\Messaging\MessageLis tenerContainer.cs:line 237
at System.Threading._ThreadPoolWaitCallback.WaitCallb ack_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Objec t userData)
at System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(Exec utionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWa itCallback(Object state)

Thank you

Kanakaraju

Mark Pollack
07-07-2007, 07:19 PM
Hi,
No trouble, I want to sort this out, and in fact, thanks for your patience. Can you post your configuration file and if possible the code fragments where you have placed transaciton attributes? I made a test program for this case and saw the issue go away, after fixing the bug, so I'm puzzled as to what is going on now. I'll look though the code in anycase to see how that code pathwy might be triggered. As a side note, do you actually want nested transactions here as compared to the transaction demarcation being at the service layer? That doesn't mean the issue won't get resolved, just want to make sure you are not doing something unecessary in your actual production code, as compared to experimenting.
Cheers,
Mark