Netflix / Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.12k stars 4.7k forks source link

Hystrix future don`t cancel the request thread in feign #1618

Open vincent-ren opened 7 years ago

vincent-ren commented 7 years ago

I have a local service to call a remote service, this local service set hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=3000, when remote service response delay 10s, client will get hystrix timeout exception, but this request thread not cancelled in 3000 Milliseconds, and it will go on and retry 5 times. Why not cancel this request thread when hystrix exception has been thrown? My hystrix-core version is 1.5.6.

mattrjacobs commented 7 years ago

Hystrix will attempt to interrupt the thread doing the work, but this is best-effort. Can you see if the networking library you're using responds to InterruptedException by stopping itself?

vincent-ren commented 7 years ago

I didn't see this InterruptedException. Need I do some configuration that make hystrix interrupt the thread effective?

mattrjacobs commented 7 years ago

This is configurable, but true by default. You may see HystrixCommandTest#testInterruptFutureOnTimeout for an example of this in action

michele-mancioppi commented 7 years ago

Also, keep in mind that interrupting the thread will not automatically result in an InterruptedException being thrown in it.

There is actually just a handful of JDK methods that will behave like this (Thread.sleep, Thread.join, Future.get, etc...), but "most" Java code and the overwhelming majority of libraries will happily ignore the interruption. Most notably: socket-level code, most JDBC operations, depending on the driver.

michele-mancioppi commented 7 years ago

By the way, I think you might find this idea of interest :-)

https://github.com/Netflix/Hystrix/issues/1643

vincent-ren commented 7 years ago

I used this Hystrix in Spring Cloud Feign, when I updated Spring Cloud Version to latest version, this cancel is effective.