Skip to content
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-37486][SQL][HIVE] set the ContextClassLoader before using the addJars in HiveClient #34742

Closed
wants to merge 1 commit into from

Conversation

kevincmchen
Copy link
Contributor

@kevincmchen kevincmchen commented Nov 29, 2021

What changes were proposed in this pull request?

In HiveSessionResourceLoader, call the function addJars of its supper class firstly and set the contextClassLoader in current thread, and then use the addJars in HiveClient. to avoid that different class loaders load the same class.

Why are the changes needed?

when using livy to execute sql statements that will use the udf jars located in lakefs, a inner filesystem in Tencent Cloud DLC. it will threw the following exceptions:

java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name

Maybe it happens in some other filesystem.

This PR fix the bug by setting the setContextClassLoader before using the addJars in HiveClient

Why are the changes needed?

fix the bug that different class loaders load the same class.

Does this PR introduce any user-facing change?

NO

How was this patch tested?

existing testsuites

…lient, to avoid the bug like 'loader constraint violation'
@github-actions github-actions bot added the SQL label Nov 29, 2021
@kevincmchen kevincmchen changed the title using the same jar class loader in HiveSessionResourceLoader and HiveClient set the setContextClassLoader before using the addJars in HiveClient Nov 29, 2021
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@HyukjinKwon
Copy link
Member

@kevincmchen mind filing a JIRA? see also https://spark.apache.org/contributing.html

@kevincmchen kevincmchen changed the title set the setContextClassLoader before using the addJars in HiveClient [SPARK-37486][SQL][HIVE] set the setContextClassLoader before using the addJars in HiveClient Nov 30, 2021
@kevincmchen kevincmchen changed the title [SPARK-37486][SQL][HIVE] set the setContextClassLoader before using the addJars in HiveClient [SPARK-37486][SQL][HIVE] set the ContextClassLoader before using the addJars in HiveClient Nov 30, 2021
@kevincmchen kevincmchen reopened this Nov 30, 2021
@kevincmchen
Copy link
Contributor Author

@kevincmchen mind filing a JIRA? see also https://spark.apache.org/contributing.html

@HyukjinKwon ok, i have created a issue about the PR and you can get the details about the bug.

@LuciferYang
Copy link
Contributor

I'm not sure if there is a counterexample that needs to call client.addJar first

@kevincmchen
Copy link
Contributor Author

kevincmchen commented Dec 1, 2021

I'm not sure if there is a counterexample that needs to call client.addJar first

I don't think supper.addJars and client.addJars are strongly dependent.
the reason why i call the supper.addJars first is to set the ContextClassLoader of current thread, to avoid that different class loaders load the same class in HiveClient。 @LuciferYang

@LuciferYang
Copy link
Contributor

Thank you for your explanation. If you are sure it will not affect the old case, I think this change is OK

@kevincmchen
Copy link
Contributor Author

Thank you for your explanation. If you are sure it will not affect the old case, I think this change is OK

ok, thx

@kevincmchen
Copy link
Contributor Author

@HyukjinKwon Could you please review the code and merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants