-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29012: NPE in ExplainTask when protologging posthook is enabled #5872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Based on the debugging, the Task#initialize() method creates conf object in HiveServer2-Handler-Pool thread and when the post hook for protologging is triggered, it created a new thread (Hive Hook Proto Log Writer) which get the query plan and at that time, ExplainTask#outputPlan() has conf as null which causes NPE.
|
@zabetak, can you please help with the review as the changes are around HIVE-22173's code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @Aggarwal-Raghav ! I left some questions/suggestions for the proposed fix.
For completeness, it would be nice to also add a unit test possibly somewhere in TestHiveProtoLoggingHook
or TestHiveHookEventProtoPartialBuilder
. Some fixes are trivial but writting also tests about them increases test coverage and guards against future regressions.
Just info: HIVE-27240, was very similar to this issue based on stacktrace, which shows the need for UT :-) |
Hi @zabetak, apologies for late reply, just wanted to let you know that I'm working on this PR and found some new issues like HIVE-29053 along the way when coming up with UT. Writing UT for this PR is not straightforward and need your opinion on this. There are 2 things to note:
What I/m thinking is, writing a itest/hive-unit integration test as below code. Because of [2], I'm not able to make qfile work as the proto data is written post test completition.
Because of NPE the QUERY Object will not be part of proto data so without fix the output should be 0, with fix it should be 1. |
The end to end approach (2.) seems a bit of an overkill. Even if the NPE is caught and logged you still have some missing entries (e.g., |
7cad6ba
to
40f11b6
Compare
40f11b6
to
8c6c480
Compare
Thanks for the suggestions/help @zabetak. I have come up with a test case highlighting the problem observed in local cluster. Can you please review and confirm if its up to the standards? |
Test failure |
8c6c480
to
53f5632
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your effort @Aggarwal-Raghav !! The prod changes LGTM.
I just have some small (mostly nit) comments regarding the test. There are two best-practices that I wanted to highlight here:
- Avoid mocking when its easy/simple to create real objects
- Avoid using java
assert
for tests
In some cases, "best-practices" can be subjective but I feel the above are applicable/beneficial in every project.
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveHookEventProtoPartialBuilder.java
Outdated
Show resolved
Hide resolved
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveHookEventProtoPartialBuilder.java
Outdated
Show resolved
Hide resolved
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveHookEventProtoPartialBuilder.java
Outdated
Show resolved
Hide resolved
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveHookEventProtoPartialBuilder.java
Outdated
Show resolved
Hide resolved
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveHookEventProtoPartialBuilder.java
Outdated
Show resolved
Hide resolved
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveHookEventProtoPartialBuilder.java
Outdated
Show resolved
Hide resolved
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveHookEventProtoPartialBuilder.java
Outdated
Show resolved
Hide resolved
|
@zabetak , I have addressed the review comments. can you please take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, will merge it soon.
Thanks for the PR @Aggarwal-Raghav ! |
What changes were proposed in this pull request?
Check HIVE-29012 for the stacktrace.
Why are the changes needed?
When protologging hook is enabled, it stores the query plan for a query as well. The conf object in ExplainTask is null for the "Hive Hook Proto Log Writer" thread.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Will see CI output + local single node setup/cluster testing