Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

kunigami
Copy link
Contributor

Differential Revision: D63346758

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 24, 2024
Copy link

netlify bot commented Sep 24, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 187f903
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/66ff08a54de7770009fa0389

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758


if (remoteResponse.errors()) {
auto errors = *remoteResponse.errors();
for (auto entry : errors) {
Copy link
Contributor

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()) {
Copy link
Contributor

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?

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758

kunigami pushed a commit to kunigami/velox that referenced this pull request Sep 27, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758

kunigami pushed a commit to kunigami/velox that referenced this pull request Sep 27, 2024
kunigami pushed a commit to kunigami/velox that referenced this pull request Sep 27, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758

Copy link
Contributor

@pedroerp pedroerp left a 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()}),
Copy link
Contributor

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>();
Copy link
Contributor

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");
Copy link
Contributor

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?

Copy link
Contributor

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?
Copy link
Contributor

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>>(
Copy link
Contributor

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);
Copy link
Contributor

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? :(

Copy link
Contributor Author

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(
Copy link
Contributor

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"
Copy link
Contributor

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.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 1, 2024
@kunigami
Copy link
Contributor Author

kunigami commented Oct 1, 2024

I removed the custom FailFunction for throwing exceptions because we can use CheckedDivideFunction for that. Also importing FailFunction from prestosql/Fail.h which returns error code instead.

Also add test for the conjunctive conditional.

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 1, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 1, 2024
Copy link
Contributor

@pedroerp pedroerp left a 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) {
Copy link
Contributor

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);
Copy link
Contributor

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

kunigami pushed a commit to kunigami/velox that referenced this pull request Oct 3, 2024
…lse (facebookincubator#11083)

Summary: Pull Request resolved: facebookincubator#11083

Reviewed By: pedroerp

Differential Revision: D63346758
@facebook-github-bot
Copy link
Contributor

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
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63346758

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in a061eb1.

Copy link

Conbench analyzed the 1 benchmark run on commit a061eb1e.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants