This is an automated email from the ASF dual-hosted git repository.

gortiz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c51d4269b Return clear error message when no common broker found for 
multi-stage query with tables from different tenants (#13235)
2c51d4269b is described below

commit 2c51d4269ba62d6a1cd32f8e90c03c201e000815
Author: Yash Mayya <[email protected]>
AuthorDate: Tue May 28 20:37:49 2024 +0530

    Return clear error message when no common broker found for multi-stage 
query with tables from different tenants (#13235)
---
 .../controller/api/resources/PinotQueryResource.java  | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
index 5dd73a5558..48d195ad2a 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java
@@ -198,7 +198,7 @@ public class PinotQueryResource {
   }
 
   private String getMultiStageQueryResponse(String query, String queryOptions, 
HttpHeaders httpHeaders,
-      String endpointUrl, String traceEnabled) {
+      String endpointUrl, String traceEnabled) throws ProcessingException {
 
     // Validate data access
     // we don't have a cross table access control rule so only ADMIN can make 
request to multi-stage engine.
@@ -237,6 +237,14 @@ public class PinotQueryResource {
             String.format("Unable to dispatch multistage query for tables: 
[%s]", tableNames))).toString();
       }
       instanceIds = findCommonBrokerInstances(brokerTenantsUnion);
+      if (instanceIds.isEmpty()) {
+        // No common broker found for table tenants
+        LOGGER.error("Unable to find a common broker instance for table 
tenants. Tables: {}, Tenants: {}",
+            tableNames, brokerTenantsUnion);
+        throw 
QueryException.getException(QueryException.BROKER_RESOURCE_MISSING_ERROR,
+            new Exception("Unable to find a common broker instance for table 
tenants. Tables: "
+                + tableNames + ", Tenants: " + brokerTenantsUnion));
+      }
     } else {
       // TODO fail these queries going forward. Added this logic to take care 
of tautologies like BETWEEN 0 and -1.
       instanceIds = _pinotHelixResourceManager.getAllBrokerInstances();
@@ -247,7 +255,7 @@ public class PinotQueryResource {
   }
 
   private String getQueryResponse(String query, @Nullable SqlNode sqlNode, 
String traceEnabled, String queryOptions,
-      HttpHeaders httpHeaders) {
+      HttpHeaders httpHeaders) throws ProcessingException {
     // Get resource table name.
     String tableName;
     Map<String, String> queryOptionsMap = 
RequestUtils.parseQuery(query).getOptions();
@@ -317,14 +325,15 @@ public class PinotQueryResource {
     return allTableConfigList;
   }
 
-  private String selectRandomInstanceId(List<String> instanceIds) {
+  private String selectRandomInstanceId(List<String> instanceIds) throws 
ProcessingException {
     if (instanceIds.isEmpty()) {
-      return QueryException.BROKER_RESOURCE_MISSING_ERROR.toString();
+      throw 
QueryException.getException(QueryException.BROKER_RESOURCE_MISSING_ERROR, "No 
broker found for query");
     }
 
     instanceIds.retainAll(_pinotHelixResourceManager.getOnlineInstanceList());
     if (instanceIds.isEmpty()) {
-      return QueryException.BROKER_INSTANCE_MISSING_ERROR.toString();
+      throw 
QueryException.getException(QueryException.BROKER_INSTANCE_MISSING_ERROR,
+          "No online broker found for query");
     }
 
     // Send query to a random broker.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to