-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transparently propagate exceptions to callers without modification #1378
Comments
Bravo @jdom. 👍 Any thoughts on whether it could be broken down into some smaller units, to allow "piloting" the changes on small scale first before we break for everybody / everything? Any way to just focus initially on (say) fixing exception thrown from storage providers [for example] or some other small-ish API surface used directly by grain code? |
Sorry for joining in late. It is anyway good that we checked those tests, to document some expectations. I think there are 2 questions here: I think the tests encode your expectations (as if Orleans was not messing with it). The expectation are actually a bit non-intuitive, as for example evident from @ReubenBond question. Most of the cases throw So first we need to agree that those are the expectation. There are not very good expectations BTW, I would prefer await not to wrap it in AggregateException, but that how async await works (I think there is also a way to avoid it, with some GetAwaiter code, I think you showed that to me). That is actually one of the critics of async await I heard - the "broken exception propagation" semantics. But that is how it is, and we are not discussing here how to change it. We simply need to adhere to the "standard" .NET async await behavior. On top of that, definitely, Orleans should not flatten or mess with exceptions at all. |
Hmmm, I think you might have gotten confused, or I am miss-understanding you now.
A faulted The trick to use In my test code I actually called If you don't want to take my word for granted just in case, you can easily modify the tests to avoid using Orleans entirely and new up the grains objects manually and call those same methods. You can also decorate the grain so that there is code in the middle that just calls |
OK, I think this is great. This is exactly what I wanted us to setup - to specify the expectations very clearly. I was obviously confused (or maybe I just forgot C# in the last couple of months). But I am sure there will be other people who will be confused as well. So maybe you can modify the tests, to specify the expected behavior, in all the different cases, with nested awaits, with multi-hop calls, with accessing .Task directly, as if there was no Orleans. You probably got the majority of them already, but missing nested awaits and multi-hop calls. Once we have that sorted, we can look at where Orleans violates it and see how we can fix it. It is probably a couple of places only (one with this double TCS) so we should be able to fix it easily. |
Hi @gabikliot, good that we are in agreement that the current expectations are right. Regarding the nested awaits or asserting I'm not sure what you meant with multi-hop calls. If it's having multiple awaits, then I answered above. If it's related to having calls to other grains, then I already had tests for those. See GrainForwardingExceptionPropagation and GrainForwardingExceptionPropagationDoesNotUnwrapAggregateExceptions |
Added test in PR #1418 |
I indeed meant GrainForwardingExceptionPropagation. You are clearly on top of it. Ignore everything I wrote above, I should have looked at yours tests more carefully before giving advice. |
Cool, although you left me thinking about edge cases, and I just created a new PR to make sure AggregateExceptions are propagated with even more fidelity, as I believe some naive implementations might brake them, because we sometimes assume the default |
So what do you think about #1415 fix? |
I think it's probably OK. Not sure if it will pass 1 of the last tests I added, but we'll see once he updates de PR. I believe @dVakulen was waiting for the tests to be merged to do it. One of them is not extremely important that it passes, as it's an edge condition, but it might be easy to fix too |
Exceptions are propagated transparently now (at least as of #7070) |
Based on a set of tests created by #1356, it's clear that if a grain throws a user-unhandled exception, then Orleans forwards it to the caller, but after it tampers a little bit with it.
It basically wraps it into an AggregateException and also flattens it (so it removes nested AggregateExceptions, messing with the stack trace and so on).
This entails a breaking change that would not be caught by compilers, but it seems that all who responded in #1356 agree that this should be fixed regardless.
The code to fix it is non entirely straightforward, as there are several levels of TaskContinuationSources in the middle (see #875 for example). It would be simpler to fix for now doing a one-off fix, but at some point there's a bigger follow up to avoid the unnecessary use of TaskCompletionSources (paying extra care of in what scheduler the continuations run). I will open another issue for it, nevertheless that might be easier to clean up with .NET 4.6
For now, the tests in ExceptionPropagationTests are being skipped. When we implement this we'll reenable them.
The text was updated successfully, but these errors were encountered: