-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-22394] [SQL] Remove redundant synchronization for metastore access #19605
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
|
Test build #83202 has finished for PR 19605 at commit
|
| * `clientLoader` in the `retryLocked` method. | ||
| */ | ||
| private def withClient[T](body: => T): T = synchronized { | ||
| private def withClient[T](body: => T): T = { |
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.
If you check the callers of withClient, you can find many callers conduct multiple client-related operations in a single body. Removing this lock might cause some concurrency issues.
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.
Then can we remove the synchronization of clientLoader in HiveClientImpl? If we synchronize withClient, then there's no need to sync each operation in body.
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.
sounds good
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.
but please make sure we only use the hive client here.
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.
Please check whether all the Hive client calls are through the Hive External Catalog. For example, addJar is an exception.
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.
I went through all methods in HiveClient having synchronization (except addJar):
getStateis used only in test.setOut,setInfoandsetErrorare only used inSparkSQLEnv.init().- all other methods are called through
HiveExternalCatalog.
So it seems addJar is the only exception.
To make addJar also go throught HiveExternalCatalog, we can pass externalCatalog instead of client at line46 in HiveSessionStateBuilder. But I don't know why we need to call newSession() at line45, where a new HiveClientImpl instance is created, with the same class loader and Hive client.
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.
Last year, we had a discussion about whether addJar should be moved to HiveExternalCatalog. See #14883
|
Also cc @srinathshankar @JoshRosen @hvanhovell @zsxwing |
|
@wzhfy Let us close this PR first. We can restart the discussion when we exposing ExternalCatalog APIs. Thanks! |
What changes were proposed in this pull request?
Before Spark 2.x, synchronization for metastore access was protected at line229 in ClientWrapper (now it's at line203 in HiveClientWrapper ).
After Spark 2.x,
HiveExternalCatalogwas introduced by SPARK-13080, where an extra level of synchronization was added at line95. That is, now we have two levels of synchronization: one isHiveExternalCatalogand the other isIsolatedClientLoaderinHiveClientImpl.But since both
HiveExternalCatalogandIsolatedClientLoaderare shared among all spark sessions, the extra level of synchronization inHiveExternalCatalogis redundant, thus can be removed.How was this patch tested?
Manual test and existing tests.