HIVE-24404: Invoke getUserName before getMSC to avoid metastore client connection been closed and retry #1685
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.
What changes were proposed in this pull request?
Modify Hive.java to make sure invoke the getUserName method before getMSC method.
Why are the changes needed?
Using spark sql drop partition will always throws exception.
hive version: 2.3.7
spark version: 3.0.1
sql:
exception:
The problem raised from the getPartitions method, where the metastore client that getMSC get will later been closed by the getUserName method. The getUserName method will close the current client during setAuth and result in the underlying thrift transport been closed.
This pr is simple that just moving calling the getUserName ahead before getMSC for preventing connection been close.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
I tested it manually by using the reproduce steps provided. And it will never throw the connection lost exception again.