InvisibleProgrammer commented on code in PR #6412:
URL: https://github.com/apache/hive/pull/6412#discussion_r3181814247
##########
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java:
##########
@@ -398,20 +398,95 @@ private TGetOperationStatusResp waitForResultSetStatus()
throws SQLException {
return statusResp;
}
+ /**
+ * Prefers the server error text from {@code
TGetOperationStatusResp.errorMessage} when it is
+ * present and plausible; falls back to a locally derived message using
+ * {@link #setQueryTimeout(int)} or the URL-seeded {@code
hive.query.timeout.seconds} value.
+ */
+ private String sqlTimeoutMessageForTimedOutState(String serverMessage) {
+ if (!needsLocalTimeoutMessageForTimedOut(serverMessage)) {
+ return serverMessage;
+ }
+ long effectiveSec = resolveEffectiveTimeoutSecondsForMessage();
+ if (effectiveSec > 0) {
+ return "Query timed out after " + effectiveSec + " seconds";
+ }
+ return "Query timed out";
+ }
+
+ private boolean needsLocalTimeoutMessageForTimedOut(String timeoutMsg) {
+ return StringUtils.isBlank(timeoutMsg)
+ || StringUtils.containsIgnoreCase(timeoutMsg, "after 0 seconds");
+ }
+
+ private long resolveEffectiveTimeoutSecondsForMessage() {
+ if (queryTimeout > 0) {
+ return queryTimeout;
+ }
+ long tracked = connection.getSessionQueryTimeoutSeconds();
+ if (tracked > 0) {
+ return tracked;
+ }
+ return 0L;
+ }
+
+ private SQLException sqlExceptionForCanceledState(TGetOperationStatusResp
statusResp) {
+ final String errMsg = statusResp.getErrorMessage();
+ final String fullErrMsg;
+ if (errMsg == null || errMsg.isEmpty()) {
+ fullErrMsg = QUERY_CANCELLED_MESSAGE;
+ } else {
+ fullErrMsg = QUERY_CANCELLED_MESSAGE + " " + errMsg;
+ }
+ return new SQLException(fullErrMsg, "01000");
+ }
+
+ /**
+ * Handles one {@code GetOperationStatus} response: applies a progress
update if in-place updates
+ * are enabled, verifies the Thrift status, and dispatches on the operation
state.
+ */
+ private void processOperationStatusResponse(TGetOperationStatusResp
statusResp) throws SQLException {
+ if (!isOperationComplete && inPlaceUpdateStream.isPresent()) {
+ inPlaceUpdateStream.get().update(statusResp.getProgressUpdateResponse());
+ }
+ Utils.verifySuccessWithInfo(statusResp.getStatus());
+ if (!statusResp.isSetOperationState()) {
+ return;
+ }
+ switch (statusResp.getOperationState()) {
+ case CLOSED_STATE:
+ case FINISHED_STATE:
+ isOperationComplete = true;
+ isLogBeingGenerated = false;
+ break;
+ case CANCELED_STATE:
+ throw sqlExceptionForCanceledState(statusResp);
+ case TIMEDOUT_STATE:
+ throw new
SQLTimeoutException(sqlTimeoutMessageForTimedOutState(statusResp.getErrorMessage()));
Review Comment:
If I interpreted it correctly, it consumes the response text, checks if we
got the same text as it set in SQLOperation, and if yes, it tries to extract
the timeout value from the string itself. It looks a little bit overkill. Does
the code execution receives the SQL State set at SQLOperation? If yes, deciding
if we get the timeout from that is way more easier.
I wonder, what is the current error message and error code on master?
--
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]