-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-31387][SQL] Handle unknown operation/session ID in HiveThriftServer2Listener #28544
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
Closed
alismess-db
wants to merge
5
commits into
apache:master
from
alismess-db:hive-thriftserver-listener-update-safer-2
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d5c946b
[SPARK-31387] Handle unknown operation/session ID in HiveThriftServer…
alismess-db cae817a
Order None pattern after Some
alismess-db aa82589
Add failsafe in case of missing pipeout dir
alismess-db f3831df
Fix indentation
alismess-db ac3a881
Separate onOperationStart into execution creation and guarded session…
alismess-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveSessionImplSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.sql.hive.thriftserver | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
|
|
||
| import org.apache.hadoop.hive.conf.HiveConf | ||
| import org.apache.hive.service.cli.OperationHandle | ||
| import org.apache.hive.service.cli.operation.{GetCatalogsOperation, OperationManager} | ||
| import org.apache.hive.service.cli.session.{HiveSessionImpl, SessionManager} | ||
| import org.mockito.Mockito.{mock, verify, when} | ||
| import org.mockito.invocation.InvocationOnMock | ||
|
|
||
| import org.apache.spark.SparkFunSuite | ||
|
|
||
| class HiveSessionImplSuite extends SparkFunSuite { | ||
| private var session: HiveSessionImpl = _ | ||
| private var operationManager: OperationManager = _ | ||
|
|
||
| override def beforeAll() { | ||
| super.beforeAll() | ||
|
|
||
| session = new HiveSessionImpl( | ||
| ThriftserverShimUtils.testedProtocolVersions.head, | ||
| "", | ||
| "", | ||
| new HiveConf(), | ||
| "" | ||
| ) | ||
| val sessionManager = mock(classOf[SessionManager]) | ||
| session.setSessionManager(sessionManager) | ||
| operationManager = mock(classOf[OperationManager]) | ||
| session.setOperationManager(operationManager) | ||
| when(operationManager.newGetCatalogsOperation(session)).thenAnswer( | ||
| (_: InvocationOnMock) => { | ||
| val operation = mock(classOf[GetCatalogsOperation]) | ||
| when(operation.getHandle).thenReturn(mock(classOf[OperationHandle])) | ||
| operation | ||
| } | ||
| ) | ||
|
|
||
| session.open(Map.empty[String, String].asJava) | ||
| } | ||
|
|
||
| test("SPARK-31387 - session.close() closes all sessions regardless of thrown exceptions") { | ||
| val operationHandle1 = session.getCatalogs | ||
| val operationHandle2 = session.getCatalogs | ||
|
|
||
| when(operationManager.closeOperation(operationHandle1)) | ||
| .thenThrow(classOf[NullPointerException]) | ||
| when(operationManager.closeOperation(operationHandle2)) | ||
| .thenThrow(classOf[NullPointerException]) | ||
|
|
||
| session.close() | ||
|
|
||
| verify(operationManager).closeOperation(operationHandle1) | ||
| verify(operationManager).closeOperation(operationHandle2) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is new from the original commit. If you don't mind, could you add some explanation about this into the PR description, @alismess-db ?
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.
We found it failing with a NullPointerException in some of the testing environments that we use at. It was related to how HiveSessionImplSuite mocked the session it created. We found it always a non-harmful check to check for NPE when searching for these pipeout files.
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.
Thank you for the explanation, @juliuszsompolski .