-
Notifications
You must be signed in to change notification settings - Fork 579
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
Fix rpc server exception handling #2917
Fix rpc server exception handling #2917
Conversation
src/v/rpc/simple_protocol.cc
Outdated
@@ -33,6 +33,9 @@ struct server_context_impl final : streaming_context { | |||
~server_context_impl() override { res.probe().request_completed(); } | |||
const header& get_header() const final { return hdr; } | |||
void signal_body_parse() final { pr.set_value(); } | |||
void body_parse_exception(const std::exception_ptr& e) final { | |||
pr.set_exception(e); |
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.
Exception ptr can be copied. Don’t you want to move the exception?
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.
done
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 is the point of std::move(e) here? exception_ptr is trivially copyable
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.
exception_ptr
has semantics similar to shared_ptr
, there is no need to copy it.
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.
Great find.
Data are always set together with header. We may leverage that fact and create appropriate constructor. Signed-off-by: Michal Maslanka <michal@vectorized.io>
Our RPC implementation support propagating server errors to the client. For this we use a `meta` field in RPC response header. The status that is included into `header::meta` field indicates whether the request is successful or its execution failed on the server side. When status indicates an error response body is empty. Fixed an error caused by the fact that we tried to parse response body before we checked the status flag. This caused parsing error and broken promise exception on the client side. Signed-off-by: Michal Maslanka <michal@vectorized.io>
Added field to response of a service that is supposed to thrown an exception during execution. This way we trigger situation in which response that contains error in header has different payload size than successful response. Signed-off-by: Michal Maslanka <michal@vectorized.io>
66f9a18
to
58507ca
Compare
58507ca
to
82a9c2f
Compare
82a9c2f
to
fc51875
Compare
Streaming context promise must be set with exception when rpc body parsing failed. This way we will forward exception to rpc transport read dispatch loop. Not setting an exception in body parsing promise would lead to `broken_promise` exception since the promise would be deleted before setting its value Signed-off-by: Michal Maslanka <michal@vectorized.io>
fc51875
to
6332a91
Compare
Cover letter
Our RPC implementation support propagating server errors to the client.
For this we use a
meta
field in RPC response header. The status thatis included into
header::meta
field indicates whether the request issuccessful or its execution failed on the server side. When status
indicates an error response body is empty.
Fixed an error caused by the fact that we tried to parse response body
before we checked the status flag. This caused parsing error and broken
promise exception on the client side.