Skip to content

Commit

Permalink
[core] Check for new query handle exception message for handling expi…
Browse files Browse the repository at this point in the history
…red queries better in query history (#4009)

- Impala changed the invalid query handle exception alerts content.
- Hue didn't capture the 'Invalid or unknown query handle' exception from Impala side. It was 'Invalid query handle' from long time.
- We are now also checking for the new exception message to be at par with all versions.
  • Loading branch information
Harshg999 authored Feb 21, 2025
1 parent 1d5dfeb commit 761e139
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/beeswax/src/beeswax/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def decorator(request, *args, **kwargs):
'message': message,
}

if re.search('database is locked|Invalid query handle|not JSON serializable', message, re.IGNORECASE):
if re.search('database is locked|Invalid query handle|Invalid or unknown query handle|not JSON serializable', message, re.IGNORECASE):
response['status'] = 2 # Frontend will not display this type of error
LOG.warning('error_handler silencing the exception: %s' % e)
return JsonResponse(response)
Expand Down
4 changes: 2 additions & 2 deletions apps/beeswax/src/beeswax/server/hive_server2_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,8 @@ def get_log(self, operation_handle):
(res, session) = self.call(self._client.GetLog, req)
return res.log
except Exception as e:
if 'Invalid query handle' in str(e):
message = 'Invalid query handle'
if 'Invalid query handle' in str(e) or 'Invalid or unknown query handle' in str(e):
message = 'Invalid or unknown query handle'
LOG.error('%s: %s' % (message, e))
else:
message = 'Error when fetching the logs of the operation.'
Expand Down
4 changes: 2 additions & 2 deletions apps/beeswax/src/beeswax/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ def execute_query(request, design_id=None, query_history_id=None):
else:
action = 'editor-results'
except QueryServerException as e:
if 'Invalid query handle' in e.message or 'Invalid OperationHandle' in e.message:
if 'Invalid query handle' in e.message or 'Invalid OperationHandle' in e.message or 'Invalid or unknown query handle' in e.message:
query_history.save_state(QueryHistory.STATE.expired)
LOG.warning("Invalid query handle", exc_info=sys.exc_info())
LOG.warning("Invalid or unknown query handle", exc_info=sys.exc_info())
action = 'editor-expired-results'
else:
raise e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def decorator(*args, **kwargs):
raise QueryError(message)
except QueryServerException as e:
message = force_unicode(str(e))
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message:
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message or 'Invalid or unknown query handle' in message:
raise QueryExpired(e)
else:
raise QueryError(message)
Expand Down
4 changes: 2 additions & 2 deletions desktop/libs/notebook/src/notebook/connectors/hiveserver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def decorator(*args, **kwargs):
raise QueryError(message)
except QueryServerException as e:
message = force_unicode(str(e))
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message:
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message or 'Invalid or unknown query handle' in message:
raise QueryExpired(e)
else:
raise QueryError(message)
Expand Down Expand Up @@ -394,7 +394,7 @@ def fetch_result(self, notebook, snippet, rows, start_over):
try:
results = db.fetch(handle, start_over=start_over, rows=rows)
except QueryServerException as ex:
if re.search('(client inactivity)|(Invalid query handle)', str(ex)) and ex.message:
if re.search('(client inactivity)|(Invalid query handle)|(Invalid or unknown query handle)', str(ex)) and ex.message:
raise QueryExpired(message=ex.message)
else:
raise QueryError(ex)
Expand Down
2 changes: 1 addition & 1 deletion desktop/libs/notebook/src/notebook/connectors/rdbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def decorator(*args, **kwargs):
return func(*args, **kwargs)
except Exception as e:
message = force_unicode(e)
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message:
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message or 'Invalid or unknown query handle' in message:
raise QueryExpired(e)
else:
raise QueryError(message).with_traceback(sys.exc_info()[2])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def decorator(*args, **kwargs):
raise
except Exception as e:
message = force_unicode(e)
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message:
if 'Invalid query handle' in message or 'Invalid OperationHandle' in message or 'Invalid or unknown query handle' in message:
raise QueryExpired(e)
else:
LOG.exception('Query Error')
Expand Down

0 comments on commit 761e139

Please sign in to comment.