Skip to content

Conversation

@gortiz
Copy link
Contributor

@gortiz gortiz commented Feb 12, 2025

This PR derives from #14994. Here, I'm applying the bigger refactors required to clean up the error hierarchy. Although the number of lines changed is pretty extensive, the actual changes are:

  1. Create some new classes in org.apache.pinot.spi.exception:
    1. PinotQueryException, which should be used as our main runtime class.
    2. QueryException, which extends PinotQueryException. This class substitutes most usages of ProcessingException, which was checked and includes tons of unnecessary thrift code. It is important to notice that this class differs from the older org.apache.pinot.common.exception.QueryException).
    3. QueryErrorCode, an enum that substitutes the integer error codes in the older QueryException.
    4. QueryErrorMessage, which contains a QueryErrorCode and two strings: one that can be shown to the user and one that could be used internally (mainly to be logged if needed).
  2. The older QueryException class (which did not actually extend the exception) has been deleted. Its responsibilities have been moved to the new classes QueryException and QueryErrorCode.
  3. Most uses of ProcessingException have been replaced with QueryException (when we actually need to throw it) or QueryErrorMessage when we need to keep the error code and messages in memory (usually to send them to other nodes).
  4. In this version, errors received by customers never include stack traces. Instead, some messages have been improved, and the idea is to continue improving them in subsequent PRs, trying to achieve something closer to what Improve exceptions broker #14994 was doing.
  5. Some error codes have changed. For example the query testQueryException("SELECT COUNT(*) FROM mytable where ArrTime = 'potato'" fails with QUERY_EXECUTION in MSE (as you can see in test BaseClusterIntegrationTestSet

@gortiz gortiz force-pushed the cleanUpQueryExceptions branch from 2308828 to 9fd0886 Compare February 12, 2025 11:44
@codecov-commenter
Copy link

codecov-commenter commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 50.55432% with 223 lines in your changes missing coverage. Please review.

Project coverage is 63.63%. Comparing base (59551e4) to head (f3afeca).
Report is 2193 commits behind head on master.

Files with missing lines Patch % Lines
...sthandler/BaseSingleStageBrokerRequestHandler.java 7.89% 35 Missing ⚠️
...requesthandler/MultiStageBrokerRequestHandler.java 0.00% 29 Missing ⚠️
...t/controller/api/resources/PinotQueryResource.java 25.00% 21 Missing ⚠️
.../pinot/query/service/dispatch/QueryDispatcher.java 17.64% 13 Missing and 1 partial ⚠️
...erator/streaming/BaseStreamingCombineOperator.java 23.07% 9 Missing and 1 partial ⚠️
...apache/pinot/query/service/server/QueryServer.java 35.71% 9 Missing ⚠️
.../apache/pinot/spi/exception/QueryErrorMessage.java 40.00% 7 Missing and 2 partials ⚠️
.../core/operator/combine/GroupByCombineOperator.java 41.66% 6 Missing and 1 partial ⚠️
...roker/requesthandler/BaseBrokerRequestHandler.java 0.00% 6 Missing ⚠️
...nMaxValueBasedSelectionOrderByCombineOperator.java 14.28% 6 Missing ⚠️
... and 30 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #15037      +/-   ##
============================================
+ Coverage     61.75%   63.63%   +1.88%     
- Complexity      207     1461    +1254     
============================================
  Files          2436     2764     +328     
  Lines        133233   155674   +22441     
  Branches      20636    23935    +3299     
============================================
+ Hits          82274    99069   +16795     
- Misses        44911    49129    +4218     
- Partials       6048     7476    +1428     
Flag Coverage Δ
custom-integration1 100.00% <ø> (+99.99%) ⬆️
integration 100.00% <ø> (+99.99%) ⬆️
integration1 100.00% <ø> (+99.99%) ⬆️
integration2 0.00% <ø> (ø)
java-11 63.59% <50.33%> (+1.88%) ⬆️
java-21 63.46% <50.55%> (+1.83%) ⬆️
skip-bytebuffers-false 63.61% <50.33%> (+1.86%) ⬆️
skip-bytebuffers-true 63.44% <50.55%> (+35.71%) ⬆️
temurin 63.63% <50.55%> (+1.88%) ⬆️
unittests 63.63% <50.55%> (+1.88%) ⬆️
unittests1 56.18% <60.88%> (+9.29%) ⬆️
unittests2 34.04% <22.39%> (+6.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gortiz gortiz marked this pull request as ready for review February 13, 2025 13:14
@gortiz gortiz requested review from Jackie-Jiang, vrajat and yashmayya and removed request for Jackie-Jiang, vrajat and yashmayya February 13, 2025 13:14
@gortiz
Copy link
Contributor Author

gortiz commented Feb 28, 2025

I've pushed several changes to fix most of the comments from @yashmayya. I think I also commented on the open discussions

@vrajat
Copy link
Contributor

vrajat commented Mar 3, 2025

I'll take a look at this PR today.

@yashmayya
Copy link
Contributor

@gortiz I didn't follow why we reintroduced the truncated stack traces in the error data blocks here? Are you planning to remove it in a follow-up PR instead? Any reason we couldn't have removed it here itself like you'd done previously?

*/
List<QueryProcessingException> getExceptions();
// TODO: Rename this method
List<BrokerResponseErrorMessage> getExceptions();
Copy link
Contributor

Choose a reason for hiding this comment

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

This change will cause backward incompatibility for clients. If you search for QueryProcessingException in:

I suggest you deprecate and keep this function as is. Anyway you plan to rename 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.

This PR will break backward compatibility, that is expected

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see, that is part of the driver. We should not break backward compatibility there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've renamed the name back to the original one

@Deprecated
@JsonIgnore
default List<QueryProcessingException> getProcessingExceptions() {
default List<BrokerResponseErrorMessage> getProcessingExceptions() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Keep as is.

@gortiz
Copy link
Contributor Author

gortiz commented Mar 5, 2025

I didn't follow why we reintroduced the truncated stack traces in the error data blocks here? Are you planning to remove it in a follow-up PR instead? Any reason we couldn't have removed it here itself like you'd done previously?

I still plan to clean up most stack traces and try to not send them to the final user. But that change should be done at the same time we improve the error codes, messages and logs. That is why I think it is better to keep the stack traces in this PR and then create one where we apply the other changes.

@gortiz
Copy link
Contributor Author

gortiz commented Mar 5, 2025

checks are green again

Comment on lines 116 to 121
try {
arguments[i] = parameterType.convert(argument, argumentType);
} catch (Exception e) {
String errorMsg = "Invalid conversion when calling " + _method + ": " + e.getMessage();
throw QueryErrorCode.QUERY_EXECUTION.asException(errorMsg, e);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is called in various ingestion paths as well, I don't think we should be using query execution error here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK, when ingestion calls this code, what they are using is to evaluate some built-in functions to apply transformations. I think it makes sense to receive query exceptions in that case. Don't you?

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 sure I agree that query processing related exceptions should ever be used in ingestion related error paths even if function related (since those are common components). But I'd prefer to not block this PR any longer, so we can discuss this further separately.

Comment on lines 116 to 121
try {
arguments[i] = parameterType.convert(argument, argumentType);
} catch (Exception e) {
String errorMsg = "Invalid conversion when calling " + _method + ": " + e.getMessage();
throw QueryErrorCode.QUERY_EXECUTION.asException(errorMsg, e);
}
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 sure I agree that query processing related exceptions should ever be used in ingestion related error paths even if function related (since those are common components). But I'd prefer to not block this PR any longer, so we can discuss this further separately.

@gortiz
Copy link
Contributor Author

gortiz commented Mar 10, 2025

I've pushed a change where I'm creating a new QueryFunctionInvoker. The old FunctionInvoker is now only called by ingestion code and the new QueryFunctionInvoker. The latter delegates to on FunctionInvoker but wraps exceptions into QueryExceptions. It also improves the error message in case the method throws an exception, removing the unnecessary InvocationTargetException in the middle and returning INTERNAL error in the unlikely case that the call fails with an IllegalAccessException

@gortiz gortiz merged commit bc567a0 into apache:master Mar 10, 2025
21 of 22 checks passed
@gortiz gortiz deleted the cleanUpQueryExceptions branch March 10, 2025 13:14
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