FrankChen021 commented on code in PR #20832:
URL: https://github.com/apache/druid/pull/20832#discussion_r4467344382


##########
server/src/main/java/org/apache/druid/server/QueryLifecycle.java:
##########
@@ -611,4 +613,34 @@ public static boolean shouldLogStackTrace(final Throwable 
e, final QueryContext
       return false;
     }
   }
+
+  /**
+   * Returns whether the exception is an error the user caused and can fix 
themselves, such as invalid SQL or an
+   * unknown table. The client already receives these in the response, and 
they are recorded in the request log and
+   * query metrics, so they don't need a WARN in the server log.
+   *
+   * The persona alone is not enough: {@link DruidException.Persona#USER} 
exceptions are also raised for timeouts,
+   * capacity limits and runtime failures that may need operator attention. So 
only categories describing a problem
+   * with the request itself are considered user errors.
+   *
+   * @param e exception
+   */
+  public static boolean isUserError(final Throwable e)
+  {
+    if (!(e instanceof DruidException)) {
+      return false;
+    }
+    final DruidException de = (DruidException) e;
+    if (de.getTargetPersona() != DruidException.Persona.USER) {
+      return false;
+    }
+    switch (de.getCategory()) {
+      case INVALID_INPUT:
+      case NOT_FOUND:
+      case UNSUPPORTED:

Review Comment:
   [P2] Keep operator-dependent unsupported failures at WARN
   
   **Finding:** This allowlist treats every USER/UNSUPPORTED DruidException as 
user-caused. `CatalogTableWriter.UnavailableCatalogTableWriter` throws exactly 
USER/UNSUPPORTED when the `druid-catalog` extension is not loaded, so a CREATE 
or ALTER request on such a deployment is downgraded to DEBUG even though the 
message requires an operator to fix cluster configuration; the WARN signal is 
lost.
   
   **Suggestion:** Narrow the predicate to unsupported errors that are resolved 
by changing the request, or classify deployment/configuration failures such as 
the unavailable catalog writer for operator attention, and add a regression 
test.



-- 
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]

Reply via email to