-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-31387] Handle unknown operation/session ID in HiveThriftServer2Listener #28155
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
[SPARK-31387] Handle unknown operation/session ID in HiveThriftServer2Listener #28155
Conversation
|
cc @wangyum
This exception could happen if an operation in ERROR or CANCELED state that was never closed by the client was already evicted from the listener state (as not-active) when the session was later closed. |
|
It is more serious in Spark 2, where the exception from the listener would bubble up all the way to session, but IMO we could also catch it in Spark 3 listener, as this PR proposes. |
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.
https://github.com/apache/spark/pull/28155/checks?check_run_id=571648817
[ERROR] [Error] /home/runner/work/spark/spark/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/service/cli/session/HiveSessionImplSuite.scala:22: object rpc is not a member of package org.apache.hive.service
[ERROR] [Error] /home/runner/work/spark/spark/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/service/cli/session/HiveSessionImplSuite.scala:37: not found: value TProtocolVersion
[ERROR] two errors found
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:4.3.0:testCompile (scala-test-compile-first) on project spark-hive-thriftserver_2.12: Execution scala-test-compile-first of goal net.alchim31.maven:scala-maven-plugin:4.3.0:testCompile failed.: CompileFailed -> [Help 1]
You can use ThriftserverShimUtils.testedProtocolVersions(0) to make it work with both hive-1.2 and hive-2.3 profile.
You must import TProtocolVersion from
e65424e to
3a842b6
Compare
|
@wangyum @gatorsmile could you take a look? |
juliuszsompolski
left a comment
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
|
ok to test |
|
Test build #122514 has finished for PR 28155 at commit
|
|
LGTM Thanks! Merged to master/3.0 |
…2Listener ### What changes were proposed in this pull request? The update methods in HiveThriftServer2Listener now check if the parameter operation/session ID actually exist in the `sessionList` and `executionList` respectively. This prevents NullPointerExceptions if the operation or session ID is unknown. Instead, a warning is written to the log. Also, in HiveSessionImpl.close(), we catch any exception thrown by `operationManager.closeOperation`. If for any reason this throws an exception, other operations are not prevented from being closed. ### Why are the changes needed? The listener's update methods would throw an exception if the operation or session ID is unknown. In Spark 2, where the listener is called directly, this hampers with the caller's control flow. In Spark 3, the exception is caught by the ListenerBus but results in an uninformative NullPointerException. In HiveSessionImpl.close(), if an exception is thrown when closing an operation, all following operations are not closed. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Unit tests Closes #28155 from alismess-db/hive-thriftserver-listener-update-safer. Authored-by: Ali Smesseim <[email protected]> Signed-off-by: gatorsmile <[email protected]> (cherry picked from commit 6994c64) Signed-off-by: gatorsmile <[email protected]>
|
Hi, @alismess-db , @juliuszsompolski , @gatorsmile . Is this tested with According to the Jenkins result, this seems to break |
|
FYI, two JDK11 jobs are recovered. I'm looking at the other failures like #28532 . |
…2Listener ### What changes were proposed in this pull request? The update methods in HiveThriftServer2Listener now check if the parameter operation/session ID actually exist in the `sessionList` and `executionList` respectively. This prevents NullPointerExceptions if the operation or session ID is unknown. Instead, a warning is written to the log. Also, in HiveSessionImpl.close(), we catch any exception thrown by `operationManager.closeOperation`. If for any reason this throws an exception, other operations are not prevented from being closed. ### Why are the changes needed? The listener's update methods would throw an exception if the operation or session ID is unknown. In Spark 2, where the listener is called directly, this hampers with the caller's control flow. In Spark 3, the exception is caught by the ListenerBus but results in an uninformative NullPointerException. In HiveSessionImpl.close(), if an exception is thrown when closing an operation, all following operations are not closed. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Unit tests Closes apache#28155 from alismess-db/hive-thriftserver-listener-update-safer. Authored-by: Ali Smesseim <[email protected]> Signed-off-by: gatorsmile <[email protected]> (cherry picked from commit 6994c64) Signed-off-by: Ali Smesseim <[email protected]>
…erver2Listener ### What changes were proposed in this pull request? This is a recreation of #28155, which was reverted due to causing test failures. The update methods in HiveThriftServer2Listener now check if the parameter operation/session ID actually exist in the `sessionList` and `executionList` respectively. This prevents NullPointerExceptions if the operation or session ID is unknown. Instead, a warning is written to the log. To improve robustness, we also make the following changes in HiveSessionImpl.close(): - Catch any exception thrown by `operationManager.closeOperation`. If for any reason this throws an exception, other operations are not prevented from being closed. - Handle not being able to access the scratch directory. When closing, all `.pipeout` files are removed from the scratch directory, which would have resulted in an NPE if the directory does not exist. ### Why are the changes needed? The listener's update methods would throw an exception if the operation or session ID is unknown. In Spark 2, where the listener is called directly, this changes the caller's control flow. In Spark 3, the exception is caught by the ListenerBus but results in an uninformative NullPointerException. In HiveSessionImpl.close(), if an exception is thrown when closing an operation, all following operations are not closed. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Unit tests Closes #28544 from alismess-db/hive-thriftserver-listener-update-safer-2. Authored-by: Ali Smesseim <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…erver2Listener ### What changes were proposed in this pull request? This is a recreation of #28155, which was reverted due to causing test failures. The update methods in HiveThriftServer2Listener now check if the parameter operation/session ID actually exist in the `sessionList` and `executionList` respectively. This prevents NullPointerExceptions if the operation or session ID is unknown. Instead, a warning is written to the log. To improve robustness, we also make the following changes in HiveSessionImpl.close(): - Catch any exception thrown by `operationManager.closeOperation`. If for any reason this throws an exception, other operations are not prevented from being closed. - Handle not being able to access the scratch directory. When closing, all `.pipeout` files are removed from the scratch directory, which would have resulted in an NPE if the directory does not exist. ### Why are the changes needed? The listener's update methods would throw an exception if the operation or session ID is unknown. In Spark 2, where the listener is called directly, this changes the caller's control flow. In Spark 3, the exception is caught by the ListenerBus but results in an uninformative NullPointerException. In HiveSessionImpl.close(), if an exception is thrown when closing an operation, all following operations are not closed. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Unit tests Closes #28544 from alismess-db/hive-thriftserver-listener-update-safer-2. Authored-by: Ali Smesseim <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit d40ecfa) Signed-off-by: Dongjoon Hyun <[email protected]>



What changes were proposed in this pull request?
The update methods in HiveThriftServer2Listener now check if the parameter operation/session ID actually exist in the
sessionListandexecutionListrespectively. This prevents NullPointerExceptions if the operation or session ID is unknown. Instead, a warning is written to the log.Also, in HiveSessionImpl.close(), we catch any exception thrown by
operationManager.closeOperation. If for any reason this throws an exception, other operations are not prevented from being closed.Why are the changes needed?
The listener's update methods would throw an exception if the operation or session ID is unknown. In Spark 2, where the listener is called directly, this hampers with the caller's control flow. In Spark 3, the exception is caught by the ListenerBus but results in an uninformative NullPointerException.
In HiveSessionImpl.close(), if an exception is thrown when closing an operation, all following operations are not closed.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Unit tests