You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/06/21 07:03:32 UTC
[GitHub] [hive] zhangbutao opened a new pull request, #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
zhangbutao opened a new pull request, #3393:
URL: https://github.com/apache/hive/pull/3393
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
3. Ensure you have added or run the appropriate tests for your PR:
4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX: Your PR title ...'.
5. Be sure to keep the PR description updated to reflect all changes.
6. Please write your PR title to summarize what this PR proposes.
7. If possible, provide a concise example to reproduce the issue for a faster review.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
See details from https://issues.apache.org/jira/browse/HIVE-26345
SQLOperation class output real exception message to jdbc client and user can amend the query based on real exception.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description, screenshot and/or a reproducable example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Hive versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
Local cluster test.
Before the PR, beeline dispaly exception:
`Error: Error running query (state=,code=0) `
With the PR, beeline dispaly exception:
`Error: Error running query: java.lang.RuntimeException: To use DbTxnManager you must set hive.support.concurrency=true (state=,code=0)`
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] zhangbutao commented on a diff in pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
zhangbutao commented on code in PR #3393:
URL: https://github.com/apache/hive/pull/3393#discussion_r974248833
##########
ql/src/java/org/apache/hadoop/hive/ql/Driver.java:
##########
@@ -511,13 +511,17 @@ public void compile(String command, boolean resetTaskIds, boolean deferClose) th
}
private void prepareForCompile(boolean resetTaskIds) throws CommandProcessorException {
- driverTxnHandler.createTxnManager();
- DriverState.setDriverState(driverState);
- prepareContext();
- setQueryId();
+ try {
Review Comment:
@zabetak Maybe I didn't describe it exactly. In fact, I tried to fix two related issues in this PR.
1. First: Beeline client can not get real exception message which is caused by the change(https://issues.apache.org/jira/browse/HIVE-23124).
2. Second: Even though the first issus is fixed, Beeline client can not get valid exception state and code in the following test:
`set hive.support.concurrency=false;`
`set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;`
`create table testacid(id int) stored as orc tblproperties('transactional'='true');`
_**Error: Error running query: java.lang.RuntimeException: To use DbTxnManager you must set hive.support.concurrency=true (state=,code=0)**_
However, In hive3, we can get valiad exception with state=42000, code=10264
**_Error: Error while compiling statement: FAILED: RuntimeException [Error 10264]: To use DbTxnManager you must set hive.support.concurrency=true (state=42000,code=10264)_**
This change was introduced by https://issues.apache.org/jira/browse/HIVE-22526, which missed handling the exception from `driverTxnHandler#createTxnManager`, i also think we should fix this.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] zabetak commented on a diff in pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
zabetak commented on code in PR #3393:
URL: https://github.com/apache/hive/pull/3393#discussion_r974185170
##########
ql/src/java/org/apache/hadoop/hive/ql/Driver.java:
##########
@@ -511,13 +511,17 @@ public void compile(String command, boolean resetTaskIds, boolean deferClose) th
}
private void prepareForCompile(boolean resetTaskIds) throws CommandProcessorException {
- driverTxnHandler.createTxnManager();
- DriverState.setDriverState(driverState);
- prepareContext();
- setQueryId();
+ try {
Review Comment:
I suppose that this try-catch block was introduced to address the [so-called regression](https://github.com/apache/hive/pull/3393#issuecomment-1207815099) from HIVE-22526 but I don't fully understand where the regression comes from.
I had a quick look in the diff introduced by HIVE-22526 but as far as I can see there the`driverTxnHandler#createTxnManager` is not wrapped in a try-catch block and it seems that the exception is not passed in `handleException` method. @zhangbutao can you explain a bit more on where exactly is the regression?
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] zhangbutao commented on pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
zhangbutao commented on PR #3393:
URL: https://github.com/apache/hive/pull/3393#issuecomment-1161346902
@belugabehr @pvary @zabetak wdyt? Thank you.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] github-actions[bot] commented on pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #3393:
URL: https://github.com/apache/hive/pull/3393#issuecomment-1320696097
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] zhangbutao commented on pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
zhangbutao commented on PR #3393:
URL: https://github.com/apache/hive/pull/3393#issuecomment-1164078451
@zabetak I checked beeline code adn hs2 code, and i still think this change should be fixed in hs2 side. Here's my test, please correct me if i am wrong. Thank you.
1. Use following query to test exception message:
`set hive.support.concurrency=false;`
`set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;`
`create table testacid(id int) stored as orc tblproperties('transactional'='true');`
2. The final result which wraps exception returned from **HS2 side**, a _**TExecuteStatementResp**_ object
https://github.com/apache/hive/blob/8f1a5b6854daf5fb4814632f9356ef5fe7bb6964/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java#L672-L679
And the final exception massage is set using _tStatus.setErrorMessage(getMessage());_, that is say client can only get simplified exception message(**_Error running query_**) instead of full exception stacktrace:
https://github.com/apache/hive/blob/8f1a5b6854daf5fb4814632f9356ef5fe7bb6964/service/src/java/org/apache/hive/service/cli/HiveSQLException.java#L131
3. The excepton displayed from the **Beeline side**:
Beeline client gets query response (**_TExecuteStatementResp_** object) from HS2 side, and uses _Utils.verifySuccessWithInfo(execResp.getStatus())_ to check status or throw exception:
https://github.com/apache/hive/blob/8f1a5b6854daf5fb4814632f9356ef5fe7bb6964/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java#L353-L354
https://github.com/apache/hive/blob/8f1a5b6854daf5fb4814632f9356ef5fe7bb6964/jdbc/src/java/org/apache/hive/jdbc/Utils.java#L378-L383
The final exception message displayed to client is _status.getErrorMessage()_, that is "**_Error running query_**" returned from HS2 side:
https://github.com/apache/hive/blob/8f1a5b6854daf5fb4814632f9356ef5fe7bb6964/service/src/java/org/apache/hive/service/cli/HiveSQLException.java#L117-L118
So, i think the root cause was that HS2 side did not return full valid exception message, and because we often use **_e.getMessage()_** to retrieve meaningful exception, we should add message content when throw a exception, e.g.:
`throw new HiveSQLException("Error running query: " + e.toString(), e);`
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] zhangbutao commented on pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
zhangbutao commented on PR #3393:
URL: https://github.com/apache/hive/pull/3393#issuecomment-1207815099
@zabetak After further investigation, i found HIVE-22526 separateed txn related codes from compile codes which lead to exception(errorCode 10264) from txn not being catched and converted into `CommandProcessorException`. I fixed this regression by catch txn exception in txn code block.
After fixing, we can get txn exception whth errorCode(10264) and state(42000).
`Error: Error while compiling statement: FAILED: RuntimeException [Error 10264]: To use DbTxnManager you must set hive.support.concurrency=true (state=42000,code=10264)`
BTW, for other exception which may not exist in` ErrorMsg class`, shoud we add a generic error code in `ErrorMsg class` or simply throw message? I have seen lots of code which handle `HiveSQLException` like this:
`throw new HiveSQLException("Error running query: " + e.toString(), e);`
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] zabetak commented on pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
zabetak commented on PR #3393:
URL: https://github.com/apache/hive/pull/3393#issuecomment-1199426280
Thanks for your detailed analysis @zhangbutao and apologies for the delay. I guess you are right that we should handle the problem in the HS2 side but I still believe that concatenating exception messages is not the right way to move forward.
If we need to inform the client (e.g., beeline) about a specific error maybe we need to use an entry from `ErrorMsg` class, add a new one, and or do something similar to what happens in [Compiler.handleException](https://github.com/apache/hive/blob/714c260e4a7c6b147c897718a33e693699267792/ql/src/java/org/apache/hadoop/hive/ql/Compiler.java#L459).
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org
[GitHub] [hive] github-actions[bot] closed pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #3393: HIVE-26345: SQLOperation class output real exception message to jdbc client
URL: https://github.com/apache/hive/pull/3393
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org