HystrixCollapser UnmanagedThreadException on command creation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

HystrixCollapser UnmanagedThreadException on command creation

matt
I'm using the ratpack hystrix module along with a globally scoped collapser.  Creating a new command via the collapser createCommand method results in an UnmanagedThreadException when attempting to initialize the HystrixRequestLog. I've noticed the recommendation to use HystrixObservableCommand with ratpack, however, the HystrixCollapser interface doesn't allow this.  

Looking for recommendations when request batching via the HystrixCollapser and integrating with Ratpack. Thanks.

ratpack.exec.UnmanagedThreadException: Operation attempted on non Ratpack managed thread 'HystrixTimer-1'
        at ratpack.exec.internal.DefaultExecution.require(DefaultExecution.java:104) ~[ratpack-core-1.4.5.jar:na]
        at ratpack.exec.Execution.current(Execution.java:81) ~[ratpack-core-1.4.5.jar:na]
        at ratpack.hystrix.internal.HystrixRegistryBackedRequestVariable.getExecution(HystrixRegistryBackedRequestVariable.java:53) ~[ratpack-hystrix-1.4.5.jar:na]
        at ratpack.hystrix.internal.HystrixRegistryBackedRequestVariable.get(HystrixRegistryBackedRequestVariable.java:34) ~[ratpack-hystrix-1.4.5.jar:na]
        at com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableHolder.get(HystrixRequestVariableHolder.java:68) ~[hystrix-core-1.5.9.jar:1.5.9]
        at com.netflix.hystrix.HystrixRequestLog.getCurrentRequest(HystrixRequestLog.java:85) ~[hystrix-core-1.5.9.jar:1.5.9]
        at com.netflix.hystrix.AbstractCommand.initRequestLog(AbstractCommand.java:286) ~[hystrix-core-1.5.9.jar:1.5.9]
        at com.netflix.hystrix.AbstractCommand.<init>(AbstractCommand.java:177) ~[hystrix-core-1.5.9.jar:1.5.9]
        at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:148) ~[hystrix-core-1.5.9.jar:1.5.9]
        at com.netflix.hystrix.HystrixCommand.<init>(HystrixCommand.java:134) ~[hystrix-core-1.5.9.jar:1.5.9]


rus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HystrixCollapser UnmanagedThreadException on command creation

rus
Do you have a failing example I can work through?

You can use the normal commands, it's just that they are blocking and need to be treated as such https://github.com/ratpack/ratpack/blob/e1a5cdf3f7201180f175b9c07527529a23e1924a/ratpack-hystrix/src/test/groovy/ratpack/hystrix/HystrixRequestCachingSpec.groovy#L84
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HystrixCollapser UnmanagedThreadException on command creation

matt
Appreciate the help Rus.

Modifying the referenced test to include a simple globally scoped collapser in the command factory. The same exception is generated during initialization of the request log.

https://gist.github.com/reevesm/daf8fcb3824ae9c3f9c2e35a3f1322ff
rus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HystrixCollapser UnmanagedThreadException on command creation

rus
Cool.  I'll dig in soon as poss.
rus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HystrixCollapser UnmanagedThreadException on command creation

rus
In reply to this post by matt
The problem is that when using a collapser the commands are ultimately created from a HystrixTimer.  And because Ratpack's Hystrix module provides a Ratpack execution backed concurrency strategy, it expects that all commands will be created from a Ratpack execution.

I can't see a way around this at the moment without being able to provide a Ratpack HystrixTimer implementation that will run on an execution.  This would also solve a different problem I've been having too.  I will have to raise a Hystrix issue for this.

It is possible to use a collapser in Ratpack just by not using that Hystrix module.  Unfortunately, doing that would would mean losing request caching and the metric streaming.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HystrixCollapser UnmanagedThreadException on command creation

matt
Thanks Rus.

I'll keep an eye out for the issue. I noticed the workaround to disable the hystrix request logging but wasn't sure about the impact so thank you for clarifying.   Would love to have the streaming metrics but fortunately request caching isn't currently a necessity for us. It still seems relatively important as far as integrating with hystrix goes to be able to use that module.
Loading...