gortiz commented on code in PR #13361:
URL: https://github.com/apache/pinot/pull/13361#discussion_r1670164895
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java:
##########
@@ -223,36 +219,22 @@ private String getMultiStageQueryResponse(String query,
String queryOptions, Htt
return QueryException.getException(QueryException.SQL_PARSING_ERROR,
new Exception("Unable to find table for this query", e)).toString();
}
- List<String> instanceIds;
- if (tableNames.size() != 0) {
- List<TableConfig> tableConfigList = getListTableConfigs(tableNames);
- if (tableConfigList == null || tableConfigList.size() == 0) {
- return
QueryException.getException(QueryException.TABLE_DOES_NOT_EXIST_ERROR,
- new Exception("Unable to find table in cluster, table does not
exist")).toString();
- }
-
- // find the unions of all the broker tenant tags of the queried tables.
- Set<String> brokerTenantsUnion = getBrokerTenantsUnion(tableConfigList);
- if (brokerTenantsUnion.isEmpty()) {
- return
QueryException.getException(QueryException.BROKER_REQUEST_SEND_ERROR, new
Exception(
- String.format("Unable to dispatch multistage query for tables:
[%s]", tableNames))).toString();
- }
- instanceIds = findCommonBrokerInstances(brokerTenantsUnion);
- if (instanceIds.isEmpty()) {
+ BrokerInfo brokerInfo;
+ if (!tableNames.isEmpty()) {
+ brokerInfo = _brokerInfoSelector.selectBrokerInfo(tableNames.toArray(new
String[0]));
+ if (brokerInfo == null) {
// No common broker found for table tenants
- LOGGER.error("Unable to find a common broker instance for table
tenants. Tables: {}, Tenants: {}",
- tableNames, brokerTenantsUnion);
+ LOGGER.error("Unable to find a common broker instance for table
tenants. Tables: {}", tableNames);
throw
QueryException.getException(QueryException.BROKER_RESOURCE_MISSING_ERROR,
- new Exception("Unable to find a common broker instance for table
tenants. Tables: "
- + tableNames + ", Tenants: " + brokerTenantsUnion));
+ new Exception("Unable to find a common broker instance for table
tenants. Tables: " + tableNames));
}
} else {
// TODO fail these queries going forward. Added this logic to take care
of tautologies like BETWEEN 0 and -1.
- instanceIds = _pinotHelixResourceManager.getAllBrokerInstances();
+ brokerInfo = _brokerInfoSelector.selectBrokerInfo();
LOGGER.error("Unable to find table name from SQL {} thus dispatching to
random broker.", query);
}
- String instanceId = selectRandomInstanceId(instanceIds);
- return sendRequestToBroker(query, instanceId, traceEnabled, queryOptions,
httpHeaders);
+ //TODO: Check if broker is online. Or is ExternalView up to date on
liveness of the broker?
Review Comment:
Is this TODO something we want to solve during this PR or after?
--
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]