IMPALA-13115: Add query id to error messages

This patch adds the query id to the error messages in both

- the result of the `get_log()` RPC, and
- the error message in an RPC response

before they are returned to the client, so that the users can easily
figure out the errored queries on the client side.

To achieve this, the query id of the thread debug info is set in the
RPC handler method, and is retrieved from the thread debug info each
time the error reporting function or `get_log()` gets called.

Due to the change of the error message format, some checks in the
impala-shell.py are adapted to keep them valid.

Testing:
- Added helper function `error_msg_expected()` to check whether an
  error message is expected. It is stricter than only using the `in`
  operator.
- Added helper function `error_msg_equal()` to check if two error
  messages are equal regardless of the query ids.
- Various test cases are adapted to match the new error message format.
- `ImpalaBeeswaxException`, which is used in tests only, is simplified
  so that it has the same error message format as the exceptions for
  HS2.
- Added an assertion to the case of killing and restarting a worker
  in the custom cluster test to ensure that the query id is in
  the error message in the client log retrieved with `get_log()`.

Change-Id: I67e659681e36162cad1d9684189106f8eedbf092
Reviewed-on: http://gerrit.cloudera.org:8080/21587
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
Xuebin Su
2024-07-16 15:52:41 +08:00
committed by Impala Public Jenkins
parent b1941c8f17
commit ad868b9947
26 changed files with 224 additions and 62 deletions

View File

@@ -46,9 +46,11 @@ from tests.common.skip import SkipIfLocal
from tests.common.test_dimensions import (
create_client_protocol_dimension, create_client_protocol_strict_dimension,
create_uncompressed_text_dimension, create_single_exec_option_dimension)
from tests.common.test_result_verifier import error_msg_expected
from tests.shell.util import (assert_var_substitution, ImpalaShell, get_impalad_port,
get_shell_cmd, get_open_sessions_metric, spawn_shell, get_unused_port,
create_impala_shell_executable_dimension, get_impala_shell_executable)
create_impala_shell_executable_dimension, get_impala_shell_executable,
stderr_get_first_error_msg)
QUERY_FILE_PATH = os.path.join(os.environ['IMPALA_HOME'], 'tests', 'shell')
@@ -1161,8 +1163,10 @@ class TestImpalaShellInteractive(ImpalaTestSuite):
assert "ParseException" in result.stderr,\
result.stderr
else:
assert "ERROR: ParseException: Unmatched string literal" in result.stderr,\
result.stderr
assert error_msg_expected(
stderr_get_first_error_msg(result.stderr),
"ParseException: Unmatched string literal"
)
def test_utf8_error_message(self, vector):
if vector.get_value('strict_hs2_protocol'):
@@ -1172,8 +1176,11 @@ class TestImpalaShellInteractive(ImpalaTestSuite):
query = "select cast(now() as string format 'yyyy年MM月dd日')"
shell.send_cmd(query)
result = shell.get_result()
assert "ERROR: Bad date/time conversion format: yyyy年MM月dd日" in result.stderr,\
result.stderr
assert error_msg_expected(
stderr_get_first_error_msg(result.stderr),
"Bad date/time conversion format: yyyy年MM月dd日"
)
def test_timezone_validation(self, vector):
"""Test that query option TIMEZONE is validated when executing a query.