-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
handle errors in remote function server when get_throwOnError() is false #11083
Conversation
✅ Deploy Preview for meta-velox canceled.
|
This pull request was exported from Phabricator. Differential Revision: D63346758 |
|
||
if (remoteResponse.errors()) { | ||
auto errors = *remoteResponse.errors(); | ||
for (auto entry : errors) { |
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.
const auto& entry
|
||
std::vector<VectorPtr> expressionResult; | ||
exprSet.eval(rows, evalCtx, expressionResult); | ||
|
||
auto evalErrors = evalCtx.errors(); | ||
if (evalErrors != nullptr && evalErrors->hasError()) { |
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.
we chatted offline, but it would be nice to find a more efficient way to serialize these strings. Maybe writing them to a StringView vector then just serializing it?
This pull request was exported from Phabricator. Differential Revision: D63346758 |
f222fe0
to
61fc63c
Compare
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Differential Revision: D63346758
This pull request was exported from Phabricator. Differential Revision: D63346758 |
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Differential Revision: D63346758
61fc63c
to
2521704
Compare
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Differential Revision: D63346758
2521704
to
264d702
Compare
This pull request was exported from Phabricator. Differential Revision: D63346758 |
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.
@kunigami awesome, thanks for making the changes! A few nits and cosmetic details, but overall looks pretty good
if (auto errorPayload = remoteResponse.get_result().errorPayload()) { | ||
auto errorsRowVector = IOBufToRowVector( | ||
*errorPayload, | ||
velox::ROW({velox::VARCHAR()}), |
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.
nit: in Velox code we usually omit the "velox" namespace, so for consistency here you can just use ROW({VARCHAR()})
*context.pool(), | ||
serde_.get()); | ||
auto errorsVector = | ||
errorsRowVector->childAt(0)->asFlatVector<velox::StringView>(); |
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.
can you VELOX_CHECK() here that the conversion above did not return nullptr?
FOLLY_ALWAYS_INLINE void | ||
call(TInput& result, const TInput& a, const TInput& b) { | ||
if (a == 0) { | ||
throw std::runtime_error("Failure"); |
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.
In general we try to make these functions not throw but to return an error status instead. Could you also add a test case that if a function returns an error status it will do the right thing?
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.
SelectivityVector defaultRows(data->size()); | ||
|
||
exprSet.eval(defaultRows, context, result); | ||
// FIXME: why is that context has no errors 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.
I'd guess that the "try" special form creates a temporary context to "swallow" the exceptions then discards them?
BufferPtr dataBuffer = | ||
AlignedBuffer::allocate<velox::StringView>(numRows, pool_.get()); | ||
|
||
auto flatVector = std::make_shared<velox::FlatVector<velox::StringView>>( |
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.
ditto; omit the "velox" namespace
if (evalErrors->hasErrorAt(i)) { | ||
auto exceptionPtr = *evalErrors->errorAt(i); | ||
try { | ||
std::rethrow_exception(*exceptionPtr); |
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.
I'm not super fluent in exception_ptr, but isn't there really a way to capture the inner exception message without re-throwing 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.
@@ -35,6 +37,11 @@ class RemoteFunctionServiceHandler | |||
std::unique_ptr<remote::RemoteFunctionRequest> request) override; | |||
|
|||
private: | |||
void handleErrors( |
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.
please add a quick documentation header to describe what the function does (triple slashes "///")
@@ -18,7 +18,9 @@ | |||
|
|||
#include <thrift/lib/cpp2/server/ThriftServer.h> | |||
#include "velox/common/memory/Memory.h" | |||
#include "velox/expression/EvalCtx.h" |
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.
could also forward declare to avoid the header->header dependency.
This pull request was exported from Phabricator. Differential Revision: D63346758 |
264d702
to
4fa4d95
Compare
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Differential Revision: D63346758
I removed the custom Also add test for the conjunctive conditional. |
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Differential Revision: D63346758
This pull request was exported from Phabricator. Differential Revision: D63346758 |
4fa4d95
to
707a97a
Compare
This pull request was exported from Phabricator. Differential Revision: D63346758 |
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Differential Revision: D63346758
707a97a
to
cc63777
Compare
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.
Awesome, thanks for adding this!
@@ -161,6 +171,53 @@ TEST_P(RemoteFunctionTest, string) { | |||
assertEqualVectors(expected, results); | |||
} | |||
|
|||
TEST_P(RemoteFunctionTest, try_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.
we usually use camel case for test names as well tryException
} | ||
std::vector<VectorPtr> errorsVector{flatVector}; | ||
auto errorRowVector = std::make_shared<RowVector>( | ||
pool_.get(), ROW({VARCHAR()}), BufferPtr(), numRows, errorsVector); |
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.
nit: you can use directly {errorsVector}
to avoid line 99
cc63777
to
3c1c7e3
Compare
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Reviewed By: pedroerp Differential Revision: D63346758
This pull request was exported from Phabricator. Differential Revision: D63346758 |
…lse (facebookincubator#11083) Summary: Pull Request resolved: facebookincubator#11083 Reviewed By: pedroerp Differential Revision: D63346758
3c1c7e3
to
187f903
Compare
This pull request was exported from Phabricator. Differential Revision: D63346758 |
This pull request has been merged in a061eb1. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
Differential Revision: D63346758