Hystrix icon indicating copy to clipboard operation
Hystrix copied to clipboard

Throwable in extended fallback is null for timeouts

Open victormferrara opened this issue 11 years ago • 14 comments

Hi,

I've been using the extended fallbacks made in #828 (which are great) and I've seen that when the execution times out the Throwable is null as the execution didn't actually fail. It would be nice to have some kind of TimeoutException there to know the real reason and don't have to dead with nulls. Looking at the code, probably the same thing happens with rejected executions.

Thanks!

victormferrara avatar Nov 13 '15 11:11 victormferrara

Is this specific to hystrix-javanica, or are you using Hystrix directly?

mattrjacobs avatar Nov 13 '15 17:11 mattrjacobs

hystrix-javanica

victormferrara avatar Nov 16 '15 09:11 victormferrara

@dmgcodevil Could you take a look at this one also, please?

mattrjacobs avatar Nov 16 '15 17:11 mattrjacobs

Yes, I'll take a look On 16 Nov 2015 12:31 p.m., "Matt Jacobs" [email protected] wrote:

@dmgcodevil https://github.com/dmgcodevil Could you take a look at this one also, please?

— Reply to this email directly or view it on GitHub https://github.com/Netflix/Hystrix/issues/974#issuecomment-157110552.

dmgcodevil avatar Nov 16 '15 18:11 dmgcodevil

@mattrjacobs btw, it largely relates to hystrix core, to get exception javanica uses getFailedExecutionException(), do you have any clue why it returns null in the case of timeout error ?

dmgcodevil avatar Nov 17 '15 15:11 dmgcodevil

Thanks for taking a look, @dmgcodevil. I'll dive in and see what's happening in hystrix-core.

mattrjacobs avatar Nov 17 '15 20:11 mattrjacobs

@victormferrara The existing semantics here are fairly subtle. The getFailedExecutionException() only refers to exceptions that arose during the execution of the work in the HystrixCommand / HystrixObservableCommand.

So in the timeout case, the execution of the command never threw a timeout, the surrounding Hystrix machinery did when it timed out that work. Likewise, in a rejection case, the execution of a command never happened, so there is no execution exception to report.

What problem are you trying to solve with this value? I know that there are other ways to query the command (isResponseTimedOut() / isResponseRejected()) that should give you the same information without giving you the actual Exception instance.

mattrjacobs avatar Nov 17 '15 21:11 mattrjacobs

@mattjacobs, he is complaining because javanica passes null in extended fallback method that is really annoying and can facilitate bogus code and I agree with it. So the question is what we can do in order to avoid passing null in fallback if a command fails because of timeout or rejected. I think I can use the methods that you suggested and create exception with corresponding text and pass it to fallback using additional argument. So your answer helped, I guess On 17 Nov 2015 4:46 p.m., "Matt Jacobs" [email protected] wrote:

@victormferrara https://github.com/victormferrara The existing semantics here are fairly subtle. The getFailedExecutionException() only refers to exceptions that arose during the execution of the work in the HystrixCommand / HystrixObservableCommand.

So in the timeout case, the execution of the command never threw a timeout, the surrounding Hystrix machinery did when it timed out that work. Likewise, in a rejection case, the execution of a command never happened, so there is no execution exception to report.

What problem are you trying to solve with this value? I know that there are other ways to query the command (isResponseTimedOut() / isResponseRejected()) that should give you the same information without giving you the actual Exception instance.

— Reply to this email directly or view it on GitHub https://github.com/Netflix/Hystrix/issues/974#issuecomment-157519144.

dmgcodevil avatar Nov 18 '15 00:11 dmgcodevil

@mattrjacobs yeah, it's exactly what @dmgcodevil explained. Thanks!

victormferrara avatar Nov 18 '15 09:11 victormferrara

hystrix-core itself is generating these Short-Circuit and Timeout exception instances. Are we missing a feature where hystrix-core exposes these exceptions, so javanica does not need to?

mattrjacobs avatar Nov 19 '15 18:11 mattrjacobs

@mattrjacobs it could be better if we had an abilitty to get such exceptions within a command

dmgcodevil avatar Nov 26 '15 16:11 dmgcodevil

@dmgcodevil Agreed. I just added #998 to add this to hystrix-core. Once it's there, hystrix-javanica can leverage this. Will note the PR in these comments so you can review

mattrjacobs avatar Nov 30 '15 17:11 mattrjacobs

The new method in hystrix-core to get this exception is now merged in master via #1008 / #1003

mattrjacobs avatar Dec 03 '15 23:12 mattrjacobs

This should be fixed in #1167

mattrjacobs avatar Apr 04 '16 21:04 mattrjacobs