Jackie-Jiang commented on code in PR #17009:
URL: https://github.com/apache/pinot/pull/17009#discussion_r2430231208
##########
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java:
##########
@@ -201,23 +198,31 @@ private byte[] serializeResponse(ServerQueryRequest
queryRequest, InstanceRespon
byte[] responseByte = null;
try {
responseByte = instanceResponse.toDataTable().toBytes();
- } catch (EarlyTerminationException e) {
- QueryException terminateException =
QueryThreadContext.getTerminateException();
- String userMsg = "Cancelled while building data table" +
(terminateException != null ? ": " + terminateException
- : StringUtils.EMPTY);
- LOGGER.error(userMsg);
- QueryErrorMessage errMsg =
QueryErrorMessage.safeMsg(QueryErrorCode.QUERY_CANCELLATION, userMsg);
- Map<String, String> queryOptions =
queryRequest.getQueryContext().getQueryOptions();
- String workloadName = QueryOptionsUtils.getWorkloadName(queryOptions);
- instanceResponse = new InstanceResponseBlock(new
ExceptionResultsBlock(errMsg));
- instanceResponse.addMetadata(MetadataKey.REQUEST_ID.getName(),
Long.toString(queryRequest.getRequestId()));
- instanceResponse.addMetadata(MetadataKey.QUERY_ID.getName(),
queryRequest.getCid());
- instanceResponse.addMetadata(MetadataKey.WORKLOAD_NAME.getName(),
workloadName);
- return serializeResponse(queryRequest, instanceResponse);
} catch (Exception e) {
-
_serverMetrics.addMeteredGlobalValue(ServerMeter.RESPONSE_SERIALIZATION_EXCEPTIONS,
1);
- LOGGER.error("Caught exception while serializing response for requestId:
{}, brokerId: {}",
- queryRequest.getRequestId(), queryRequest.getBrokerId(), e);
+ long requestId = queryRequest.getRequestId();
+ String brokerId = queryRequest.getBrokerId();
+ // First check terminate exception and use it as the response if exists.
We want to return the termination reason
+ // when query is explicitly terminated.
+ QueryException queryException =
QueryThreadContext.getTerminateException();
+ // Do not log exception when query is explicitly terminated
+ if (queryException == null && e instanceof QueryException) {
+ queryException = (QueryException) e;
Review Comment:
This can be `EarlyTerminationException` which is not related to
serialization. Let me separate the part extracting data table and the part
serializing it to be more robust
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]