Repository: hive Updated Branches: refs/heads/master d81aed31d -> 6df4d6f04
HIVE-19065: Metastore client compatibility check should include syncMetaStoreClient (Daniel Dai, reviewed by Thejas Nair) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/6df4d6f0 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/6df4d6f0 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/6df4d6f0 Branch: refs/heads/master Commit: 6df4d6f047f0ca04c6f1faa8e76144dbee408294 Parents: d81aed3 Author: Daniel Dai <dai...@gmail.com> Authored: Fri Apr 6 11:00:32 2018 -0700 Committer: Daniel Dai <dai...@gmail.com> Committed: Fri Apr 6 11:00:32 2018 -0700 ---------------------------------------------------------------------- .../hive/metastore/SynchronizedMetaStoreClient.java | 9 +++++++++ .../java/org/apache/hadoop/hive/ql/metadata/Hive.java | 12 ++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/6df4d6f0/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java b/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java index 8826724..f87a6aa 100644 --- a/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java +++ b/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hive.metastore; import java.util.List; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.common.ValidTxnList; import org.apache.hadoop.hive.metastore.api.AlreadyExistsException; import org.apache.hadoop.hive.metastore.api.EnvironmentContext; @@ -111,4 +112,12 @@ public final class SynchronizedMetaStoreClient { public synchronized void close() { client.close(); } + + public boolean isSameConfObj(Configuration c) { + return client.isSameConfObj(c); + } + + public boolean isCompatibleWith(Configuration c) { + return client.isCompatibleWith(c); + } } http://git-wip-us.apache.org/repos/asf/hive/blob/6df4d6f0/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index eed37a1..38fbb7b 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -333,7 +333,7 @@ public class Hive { boolean doRegisterAllFns) throws HiveException { Hive db = hiveDB.get(); if (db == null || !db.isCurrentUserOwner() || needsRefresh - || (c != null && db.metaStoreClient != null && !isCompatible(db, c, isFastCheck))) { + || (c != null && !isCompatible(db, c, isFastCheck))) { db = create(c, false, db, doRegisterAllFns); } if (c != null) { @@ -366,11 +366,15 @@ public class Hive { } private static boolean isCompatible(Hive db, HiveConf c, boolean isFastCheck) { - return isFastCheck - ? db.metaStoreClient.isSameConfObj(c) : db.metaStoreClient.isCompatibleWith(c); + if (isFastCheck) { + return (db.metaStoreClient == null || db.metaStoreClient.isSameConfObj(c)) + && (db.syncMetaStoreClient == null || db.syncMetaStoreClient.isSameConfObj(c)); + } else { + return (db.metaStoreClient == null || db.metaStoreClient.isCompatibleWith(c)) + && (db.syncMetaStoreClient == null || db.syncMetaStoreClient.isCompatibleWith(c)); + } } - public static Hive get() throws HiveException { return get(true); }