jasperjiaguo commented on code in PR #11710: URL: https://github.com/apache/pinot/pull/11710#discussion_r1341666747
########## pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java: ########## @@ -168,6 +169,19 @@ protected byte[] processQueryAndSerialize(ServerQueryRequest queryRequest, Execu byte[] responseBytes = serializeResponse(queryRequest, instanceResponse); + Map<String, String> queryOptions = queryRequest.getQueryContext().getQueryOptions(); + Long maxResponseByteLength = QueryOptionsUtils.getMaxSerializedResponseLengthPerServer(queryOptions); + if (maxResponseByteLength != null && responseBytes.length > maxResponseByteLength) { + String errorMessage = String.format("Serialized response exceeds threshold for requestId %d from broker %s", + queryRequest.getRequestId(), queryRequest.getBrokerId()); + LOGGER.error(errorMessage); + // TODO(Vivek): Add a metric indicating the number of such exceptions. + instanceResponse = new InstanceResponseBlock(); + instanceResponse.addException(QueryException.getException(QueryException.INTERNAL_ERROR, errorMessage)); Review Comment: or use QUERY_CANCELLATION_ERROR for which we've set the error code to 503(Service Unavailable) ########## pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java: ########## @@ -168,6 +169,19 @@ protected byte[] processQueryAndSerialize(ServerQueryRequest queryRequest, Execu byte[] responseBytes = serializeResponse(queryRequest, instanceResponse); + Map<String, String> queryOptions = queryRequest.getQueryContext().getQueryOptions(); + Long maxResponseByteLength = QueryOptionsUtils.getMaxSerializedResponseLengthPerServer(queryOptions); + if (maxResponseByteLength != null && responseBytes.length > maxResponseByteLength) { + String errorMessage = String.format("Serialized response exceeds threshold for requestId %d from broker %s", + queryRequest.getRequestId(), queryRequest.getBrokerId()); + LOGGER.error(errorMessage); + // TODO(Vivek): Add a metric indicating the number of such exceptions. + instanceResponse = new InstanceResponseBlock(); + instanceResponse.addException(QueryException.getException(QueryException.INTERNAL_ERROR, errorMessage)); Review Comment: or use QUERY_CANCELLATION_ERROR for which we've set the error code to 503(Service Unavailable)? -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org