Limit up to 10 unavailable segments to be printed in the query exception
@@ -97,7 +97,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@SuppressWarnings("UnstableApiUsage")
@ThreadSafe
public abstract class BaseBrokerRequestHandler implements BrokerRequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(BaseBrokerRequestHandler.class);
@@ -106,6 +105,7 @@ public abstract class BaseBrokerRequestHandler implements BrokerRequestHandler {
private static final Expression FALSE = RequestUtils.getLiteralExpression(false);
private static final Expression TRUE = RequestUtils.getLiteralExpression(true);
private static final Expression STAR = RequestUtils.getIdentifierExpression("*");
+ private static final int MAX_UNAVAILABLE_SEGMENTS_TO_PRINT_IN_QUERY_EXCEPTION = 10;
protected final PinotConfiguration _config;
protected final BrokerRoutingManager _routingManager;
@@ -608,7 +608,14 @@ public abstract class BaseBrokerRequestHandler implements BrokerRequestHandler {
List<ProcessingException> exceptions = new ArrayList<>();
if (numUnavailableSegments > 0) {
- String errorMessage = String.format("%d segments %s unavailable", numUnavailableSegments, unavailableSegments);
+ String errorMessage;
+ if (numUnavailableSegments > MAX_UNAVAILABLE_SEGMENTS_TO_PRINT_IN_QUERY_EXCEPTION) {
+ errorMessage = String.format("%d segments unavailable, sampling %d: %s", numUnavailableSegments,
+ MAX_UNAVAILABLE_SEGMENTS_TO_PRINT_IN_QUERY_EXCEPTION,
+ unavailableSegments.subList(0, MAX_UNAVAILABLE_SEGMENTS_TO_PRINT_IN_QUERY_EXCEPTION));
+ } else {
+ errorMessage = String.format("%d segments unavailable: %s", numUnavailableSegments, unavailableSegments);
+ }
exceptions.add(QueryException.getException(QueryException.BROKER_SEGMENT_UNAVAILABLE_ERROR, errorMessage));
}
