LantaoJin commented on a change in pull request #28938:
URL: https://github.com/apache/spark/pull/28938#discussion_r510009386



##########
File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala
##########
@@ -95,11 +100,20 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, 
hadoopConf: Configurat
   }
 
   /**
-   * Run some code involving `client` in a [[synchronized]] block and wrap 
certain
+   * Run some code involving `client` in a [[ReadWriteLock]] and wrap certain
    * exceptions thrown in the process in [[AnalysisException]].
+   *
+   * @param db to specify the place of the operation act on.
+   * @param writeLock to specify it is a write lock.
    */
-  private def withClient[T](body: => T): T = synchronized {
+  private def withClient[T](db: String = "", writeLock: Boolean = false) 
(body: => T): T = {

Review comment:
       You are right, you remind me to check the diff between our code and 
spark3 again. We changed many objects in `HiveExternalCatalog.client` 
non-shared. For example,
   In spark3
   ```scala
     val state: SessionState = ...
   
     override val userName = 
UserGroupInformation.getCurrentUser.getShortUserName
   ```
   and our code
   ```scala
     // get the state from thread-local
     def state: SessionState = ...
   
     // This should be def instead of val. Since it may be invoked in different 
ugi
     // in thrift server, we need re-evaluate it every time it is invoked, and 
internally
     // it obtains the user name via the current ugi.
     private def userName = conf.getUser
   ```
   
   Em, let me remark it to WIP.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to