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

Report function name for unknown exceptions during execution #14987

Merged
merged 14 commits into from
Oct 25, 2023

Conversation

kgyrtkirk
Copy link
Member

@kgyrtkirk kgyrtkirk commented Sep 14, 2023

In case some unexpected issue happens in one of the Function-s the exception may get out without being wrapped in a more informational message.

Which may lead to that users see NullPointerException after executing a query which doesn't really give any detail how to continue.

These changes wrap these most likely unexpected exception in a "exception happened in function X" cover; so that the error might be a bit more specific where the issue happened.

throw e;
}
catch (Exception e) {
throw DruidException.defensive().build(e, "Invocation of function '%s' encountered exception.", name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some other category would make more sense than "defensive". Defensive is sort of like an assert (it signals that we believe this should never happen unless there's a bug) but we do in fact expect functions to throw exceptions under "normal" conditions sometimes. (Like if they receive arguments of the wrong type, etc)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case the invoked function have already thrown out some reasonable exception (DruidException) - that's not touched at all - because a catch above caught it.

I wanted to add this to catch cases in which some unexpected issue happened while the function was processing....so that we don't let out a NullPointerException ; instead say that "Invocation of function x encountered ... " - it may give some help to the user what might have been the problem ; and it could give better error message to support instead of just refering to it as an NPE.

or do you think it would be better to repackage also normal DruidExcpetion-s and re-packaged? - and rethrown them with a bit more context?
so it will be something like:

DruidException: while invoking function x
caused by:
DruidException: Can't process an empty set because it Sunday!
``

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. I thought this was wrapping all exceptions, but misread it.

In the case I'm wondering if the "user-caused" exceptions (bad input) thrown by functions are all proper DruidExceptions? In that case a defensive might make sense here. We just want to avoid defensive for anything that isn't a code bug on our end.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - other exceptions are good; the case was like: an unexpected issue happened - and the NPE bubbled up to the top. Giving little-to-no detail to the user about what happened; as the message didn't contained anything usefull.

I think if the user could see a bit friendlier message - it might give a starting point to either start narrowing it down the issue; or try to work it around

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should surface as runtime_failure IMO. Both defensive and runtime_failure map to same error code.

@kgyrtkirk kgyrtkirk marked this pull request as ready for review September 28, 2023 10:50
@kgyrtkirk
Copy link
Member Author

I've re-run the tests - and they seem to be green

@gianm Could you please take another look?

@gianm gianm merged commit f48263b into apache:master Oct 25, 2023
74 checks passed
CaseyPan pushed a commit to CaseyPan/druid that referenced this pull request Nov 17, 2023
…14987)

* provide function name when unknown exceptions are encountered

* fix keywords/etc

* fix keywrod order - regex excercise

* add test

* add check&fix keywords

* decoupledIgnore

* Revert "decoupledIgnore"

This reverts commit e922c82.

* unpatch Function

* move to a different location

* checkstyle
@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants