thread hoping is when the runtime decides to move your code from one thread
to another.Take a look at async controllers / pages, that is what I am
talking about.

You need to associate the current unit of work with the current operation,
and make sure that things like AR are aware of that.

On Mon, Jan 26, 2009 at 9:17 AM, Tim Scott <[email protected]>wrote:

>
> I never heard the term "thread hopping," but it seems to describe
> what's happening.  I have no clue how such a thing can happen.  One
> thing I notice is that, although my WCF calls are not explicitly
> asyncronous, the stack trace seems to show that under the hood, they
> are.  Perhaps this has something to do with it.  I originally got this
> class from Jan Van Ryswyck:
>
>
> http://vanryswyckjan.blogspot.com/2008/07/integrating-castle-windsor-and.html
>
> I left a comment, and he replied that he had seen this issue and plans
> to post about it.
>
> I wonder if my modified code is a real solution.  The instance that I
> am disposing is explicitly the current one, so the
> ScopeMachineryException is avoided, but because it is apparently not
> always the same one started in BeginInvoke, perhaps clean up is not
> properly handled.
>
>
> On Jan 25, 5:51 pm, Ayende Rahien <[email protected]> wrote:
> > thread hopping?
> >
> > On Sun, Jan 25, 2009 at 2:52 PM, Tim Scott <[email protected]
> >wrote:
> >
> >
> >
> > > Okay, I think can explain the different behavior on dev versus QA.  My
> > > dev box is XP, which uses IIS 5, which has a limit of 10 connections.
> > > This limit is being hit before the ScopeMachineryException shows up.
> >
> > > I have been able to catch and log the exception on QA.  Here is the
> > > stack trace:
> >
> > > ICallContextInitializer.BeforeInvoke threw an exception of type
> > > Castle.ActiveRecord.Framework.Scopes.ScopeMachineryException:
> > > Tried to unregister a scope that is not the active one
> > >  Stack Trace:
> > >   at
> >
> > >
> Castle.ActiveRecord.Framework.Scopes.AbstractThreadScopeInfo.UnRegisterScope
> > > (ISessionScope scope)
> > >   at
> > >
> Castle.ActiveRecord.Framework.Scopes.ThreadScopeAccessor.UnRegisterScope
> > > (ISessionScope scope)
> > >   at Castle.ActiveRecord.Framework.Scopes.AbstractScope.Dispose()
> > >   at Rhino.Commons.ActiveRecordUnitOfWorkAdapter.Dispose() in c:
> > > \SANDBOX\RhinoTools\rhino-commons\Rhino.Commons.ActiveRecord\UnitOfWork
> > > \ActiveRecordUnitOfWorkAdapter.cs:line 100
> > >   at Mojo.Common.WebServices.UnitOfWorkContext.AfterInvoke(Object
> > > correlationState) in c:\cruisecontrol\mojo\checkout\src\Mojo.Common
> > > \WebServices\UnitOfWorkContext.cs:line 31
> > >    at
> >
> > >
> System.ServiceModel.Dispatcher.DispatchOperationRuntime.UninitializeCallContextCore
> > > (MessageRpc& rpc)
> >
> > > Here is the class where the error occurs:
> >
> > > public class UnitOfWorkContext : ICallContextInitializer
> > > {
> > >    private IUnitOfWork _unitOfWork;
> >
> > >    public Object BeforeInvoke(InstanceContext instanceContext,
> > > IClientChannel channel, Message message)
> > >    {
> > >        _unitOfWork = UnitOfWork.Start();
> > >        return null;
> > >    }
> >
> > >    public void AfterInvoke(Object correlationState)
> > >    {
> > >        if (_unitOfWork != null)
> > >        {
> > >            _unitOfWork.Dispose();
> > >            _unitOfWork = null;
> > >        }
> > >    }
> > > }
> >
> > > Thoughts?
> >
> > > On Jan 24, 4:55 pm, Ayende Rahien <[email protected]> wrote:
> > > > I don't see it even remotely related to those, except for the
> machinery
> > > > exception
> >
> > > > On Sat, Jan 24, 2009 at 5:46 PM, Tim Scott <
> [email protected]
> > > >wrote:
> >
> > > > > No, firewall is turned off.  If it was firewall, I would expect to
> get
> > > > > the error all the time.  Since it happens under load, must be some
> > > > > concurrency issue.  BTW, I am using this:
> >
> > > > >
> http://elegantcode.com/2008/07/14/integrating-castle-windsor-and-nhib.
> > > ..
> >
> > > > > ...to make UnitOfWorkApplication work with WCF.  Perhaps that's a
> > > > > clue.
> >
> > > > > On Jan 24, 4:24 pm, Ayende Rahien <[email protected]> wrote:
> > > > > > No idea.
> > > > > > do you have some firewall?
> >
> > > > > > On Sat, Jan 24, 2009 at 5:20 PM, Tim Scott <
> > > [email protected]
> > > > > >wrote:
> >
> > > > > > > When I run the load test against the QA machine, my application
> > > does
> > > > > > > not log any errors.  The only evidence of error is in the
> Windows
> > > > > > > event log, which is what I put in my original message.
> >
> > > > > > > I ran the exact same load test against my dev machine, and my
> app
> > > does
> > > > > > > log errors, but they are different.  I cannot explain the
> different
> > > > > > > behavior.  I am getting two exceptions coming from the same
> place.
> > > > > > > Here they are.  As you can see they happen a ticks apart.  I
> think
> > > > > > > this is definitely off topic.  I'm guessing the
> ScopeMachineryError
> > > on
> > > > > > > QA is coming from Rhino Commons code but only as a side effect
> of
> > > the
> > > > > > > real problem.  I think the real problem is some misuse of WCF.
> > >  Sorry
> > > > > > > again that it's off topic, but any thoughts are appreciated.
> >
> > > > > > > Again, this error does not happen until I put the system under
> > > load.
> >
> > > > > > > 2009-01-24 14:48:58,140 [timscottmacxp1] [24] [] ERROR:
> > > > > > > System.ServiceModel.Security.MessageSecurityException: The HTTP
> > > > > > > request was forbidden with client authentication scheme
> > > 'Anonymous'.
> > > > > > > ---> System.Net.WebException: The remote server returned an
> error:
> > > > > > > (403) Forbidden.
> > > > > > >   at System.Net.HttpWebRequest.GetResponse()
> > > > > > >   at
> >
> > >
> System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply
> > > > > > > (TimeSpan timeout)
> > > > > > >   --- End of inner exception stack trace ---
> >
> > > > > > > Server stack trace:
> > > > > > >   at
> >
> > > System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> > > System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> >
> > > System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
> > > > > > > timeout)
> > > > > > >   at
> >
> > >
> System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> >
> > > System.ServiceModel.Security.SecurityUtils.OpenTokenProviderIfRequired
> > > > > > > (SecurityTokenProvider tokenProvider, TimeSpan timeout)
> > > > > > >   at
> System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> >
> > > System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
> > > > > > > timeout)
> > > > > > >   at
> >
> > >
> System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
> > > > > > > timeout)
> > > > > > >   at
> >
> > >
> System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation
> > > > > > > (SecuritySessionOperation operation, EndpointAddress target,
> Uri
> > > via,
> > > > > > > SecurityToken currentToken, TimeSpan timeout)
> > > > > > >   at
> >
> > >
> System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> System.IdentityModel.Selectors.SecurityTokenProvider.GetToken
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> >
> > >
> System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen
> > > > > > > (TimeSpan timeout)
> > > > > > >   at
> System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
> > > > > > > timeout)
> > > > > > >   at
> System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan
> > > > > > > timeout)
> > > > > > >   at
> System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
> > > > > > > timeout)
> > > > > > >   at
> >
> > >
> System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call
> > > > > > > (ServiceChannel channel, TimeSpan timeout)
> > > > > > >   at
> >
> > > System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce
> > > > > > > (TimeSpan timeout, CallOnceManager cascade)
> > > > > > >   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened
> > > > > > > (TimeSpan timeout)
> > > > > > >   at System.ServiceModel.Channels.ServiceChannel.Call(String
> > > action,
> > > > > > > Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
> > > Object
> > > > > > > [] outs, TimeSpan timeout)
> > > > > > >   at System.ServiceModel.Channels.ServiceChannel.Call(String
> > > action,
> > > > > > > Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
> > > Object
> > > > > > > [] outs)
> > > > > > >   at
> System.ServiceModel.Channels.ServiceChannelProxy.InvokeService
> > > > > > > (IMethodCallMessage methodCall, ProxyOperationRuntime
> operation)
> > > > > > >   at
> > > System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
> > > > > > > message)
> >
> > > > > > > Exception rethrown at [0]:
> > > > > > >   at
> System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage
> > > > > > > (IMessage reqMsg, IMessage retMsg)
> > > > > > >   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke
> > > > > > > (MessageData& msgData, Int32 type)
> > > > > > >   at
> >
> > >
> Mojo.Common.WebServices.ServiceContracts.IActivationService.ActivateInvitationWithDemoGiftCodeReward
> > > > > > > (Int32 clientId, String email)
> > > > > > >   at
> >
> > >
> Mojo.Common.WebServices.ServiceFacade.ActivationServiceFacade.<>c__DisplayClassa.<ActivateInvitationWithDemoGiftCodeReward>b__9
> > > > > > > (IActivationService x) in
> C:\LunaverseRepositories\MotivatorSystems
> > > > > > > \Mojo\src\Mojo.Common\WebServices\ServiceFacade
> > > > > > > \ActivationServiceFacade.cs:line 29
> > > > > > >   at
> >
> > >
> Mojo.Common.WebServices.ServiceFacade.ServiceFacadeBase`1.<>c__DisplayClass1`1.<Use>b__0
> > > > > > > (T proxy) in C:\LunaverseRepositories\MotivatorSystems\Mojo\src
> > > > > > >
> \Mojo.Common\WebServices\ServiceFacade\ServiceFacadeBase.cs:line 53
> > > > > > >   at
> Mojo.Common.WebServices.ServiceFacade.ServiceFacadeBase`1.Use
> > > > > > > (Action`1 action) in
> > > C:\LunaverseRepositories\MotivatorSystems\Mojo\src
> > > > > > >
> \Mojo.Common\WebServices\ServiceFacade\ServiceFacadeBase.cs:line 31
> > > > > > >   at
> Mojo.Common.WebServices.ServiceFacade.ServiceFacadeBase`1.Use
> > > > > > > [TResult](Func`2 function) in
> > > C:\LunaverseRepositories\MotivatorSystems
> > > > > > > \Mojo\src\Mojo.Common\WebServices\ServiceFacade
> > > > > > > \ServiceFacadeBase.cs:line 51
> > > > > > >   at
> >
> > >
> Mojo.Common.WebServices.ServiceFacade.ActivationServiceFacade.ActivateInvitationWithDemoGiftCodeReward
> > > > > > > (Int32 clientId, String email) in C:\LunaverseRepositories
> > > > > > >
> \MotivatorSystems\Mojo\src\Mojo.Common\WebServices\ServiceFacade
> > > > > > > \ActivationServiceFacade.cs:line 29
> > > > > > >   at
> >
> > > Mojo.Presentation.Service.Impl.PresentationService.ActivateInvtation
> > > > > > > (ActivateInvitationRequest request) in C:\LunaverseRepositories
> >
> > ...
> >
> > read more ยป
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to