-
Notifications
You must be signed in to change notification settings - Fork 5
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
New failure propagation #100
Conversation
…on every failure with Code UNKNOWN. In other words, a failure is non-terminal when code is UNKNOWN, otherwise is terminal. * Now GrpcServerCallListenerAdaptor won't erase the cause anymore when getting an exception from the user code, because we need it for syscalls.fail(cause)
Unit Test Results144 tests +12 144 ✔️ +12 9s ⏱️ -1s Results for commit 2bb3045. ± Comparison against base commit 0093ff2. This pull request removes 2 and adds 14 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
Initially I wanted to use as rule for "terminal/non terminal" the following:
Essentially keeping away the condition of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for creating this PR @slinkydeveloper. The changes look good to me. Before merging, it would be good to somehow document the behavior for our users (I guess via some JavaDocs, later once we have a Java SDK documentation then also there).
sdk-core-impl/src/main/java/dev/restate/sdk/core/impl/RestateServerCall.java
Outdated
Show resolved
Hide resolved
@@ -202,6 +203,9 @@ public void exitSideEffectBlockWithException( | |||
if (protocolException.isPresent()) { | |||
throw protocolException.get(); | |||
} | |||
if (!(toWrite instanceof StatusRuntimeException)) { | |||
throw (RuntimeException) toWrite; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this cast safe? Can't this be any other unchecked exception here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the side effect lambda cannot through non-RuntimeException. In any case, I added a wrapping to avoid any future unsafe usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we wrapping all unchecked exceptions in a RuntimeException
(also Error
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this stage we cannot really do anything else, can't we? it's the caller that perhaps shouldn't catch Error
when invoking the side effect call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW check the latest code
@@ -202,6 +203,9 @@ public void exitSideEffectBlockWithException( | |||
if (protocolException.isPresent()) { | |||
throw protocolException.get(); | |||
} | |||
if (!(toWrite instanceof StatusRuntimeException)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it is a StatusRuntimeException
and code == UNKNOWN
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be treated as non-terminal I guess. Perhaps let me align this with #100 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for resolving my comments. LGTM. +1 for merging.
Fix #94. This PR implements the new failure propagation. The logic is the following:
ProtocolException
, user thrown exceptions, etc.