Repository: hive
Updated Branches:
  refs/heads/branch-1 0d9689657 -> 3fe412417


HIVE-11935: Race condition in  HiveMetaStoreClient: isCompatibleWith and close 
(Daniel Dai, Reviewed by Alan Gates)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/3fe41241
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/3fe41241
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/3fe41241

Branch: refs/heads/branch-1
Commit: 3fe4124178b8c5a413b07b400c9b5df6360f6d29
Parents: 0d96896
Author: Daniel Dai <da...@hortonworks.com>
Authored: Fri Dec 18 12:06:16 2015 -0800
Committer: Daniel Dai <da...@hortonworks.com>
Committed: Fri Dec 18 12:06:57 2015 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/3fe41241/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
----------------------------------------------------------------------
diff --git 
a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java 
b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index e1ab1d5..6ee48c6 100644
--- 
a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ 
b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -287,13 +287,16 @@ public class HiveMetaStoreClient implements 
IMetaStoreClient {
 
   @Override
   public boolean isCompatibleWith(HiveConf conf) {
-    if (currentMetaVars == null) {
+    // Make a copy of currentMetaVars, there is a race condition that
+       // currentMetaVars might be changed during the execution of the method
+    Map<String, String> currentMetaVarsCopy = currentMetaVars;
+    if (currentMetaVarsCopy == null) {
       return false; // recreate
     }
     boolean compatible = true;
     for (ConfVars oneVar : HiveConf.metaVars) {
       // Since metaVars are all of different types, use string for comparison
-      String oldVar = currentMetaVars.get(oneVar.varname);
+      String oldVar = currentMetaVarsCopy.get(oneVar.varname);
       String newVar = conf.get(oneVar.varname, "");
       if (oldVar == null ||
           (oneVar.isCaseSensitive() ? !oldVar.equals(newVar) : 
!oldVar.equalsIgnoreCase(newVar))) {

Reply via email to