-
Notifications
You must be signed in to change notification settings - Fork 561
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
rpc: pass requests by value #15971
rpc: pass requests by value #15971
Conversation
Pass RPC requests by value, as we start to write some handlers using coroutines, it can be a footgun to access have a suspension point, then the request is destroyed. An example that motivated this: ```c++ ss::future<reply> service::handle(request&& r, rpc::streaming_context&) { co_await ss::coroutine::switch_to(get_scheduling_group()); co_return co_await handle_request(std::move(r)); } ``` In this case `r` is destroyed because the coroutine does not own the value, and handle request would have a stack-use-after-return issue. Now that we pass by value, we don't have to remember to move the value into the current method. Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
new failures in https://buildkite.com/redpanda/redpanda/builds/43498#018cdb8f-4871-4c46-9031-75627717886a:
|
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.
nice
CI Failure: #15972 |
ducktape was retried in https://buildkite.com/redpanda/redpanda/builds/43498#018cdcf4-c91a-4504-8509-4155b50501b6 |
I wonder if we should enforce all types in RPC via a concept to be either small pods of say 16bytes or non copyable and non copy assignment. |
Yeah not against making stuff explicitly copyable only, or doing this via serde where you have to add a flag to opt into copy constructor if not trivially copyable. |
Pass RPC requests by value, as we start to write some handlers using
coroutines, it can be a footgun to access have a suspension point, then
the request is destroyed. An example that motivated this:
In this case
r
is destroyed because the coroutine does not own thevalue, and handle request would have a stack-use-after-return issue.
Now that we pass by value, we don't have to remember to move the value
into the current method.
Fixes: https://github.com/redpanda-data/core-internal/issues/898
Backports Required
Release Notes