From 470d9c8ab20d2c3e4f57883ac4e3e72d34483ba8 Mon Sep 17 00:00:00 2001 From: ctang Date: Thu, 2 Jul 2015 09:56:40 -0400 Subject: [PATCH] HIVE-11157: Hive.get(HiveConf) returns same Hive object to different user sessions (Chaoyu Tang, reviewed by Jimmy Xiang) --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 a6193ba85307..d89aafc5a17c 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 @@ -194,7 +194,7 @@ public static Hive get(Configuration c, Class clazz) throws HiveException { /** * Gets hive object for the current thread. If one is not initialized then a * new one is created If the new configuration is different in metadata conf - * vars then a new one is created. + * vars, or the owner will be different then a new one is created. * * @param c * new Hive Configuration @@ -204,7 +204,7 @@ public static Hive get(Configuration c, Class clazz) throws HiveException { */ public static Hive get(HiveConf c) throws HiveException { Hive db = hiveDB.get(); - if (db == null || + if (db == null || !db.isCurrentUserOwner() || (db.metaStoreClient != null && !db.metaStoreClient.isCompatibleWith(c))) { return get(c, true); } @@ -292,6 +292,9 @@ private void close() { metaStoreClient.close(); metaStoreClient = null; } + if (owner != null) { + owner = null; + } } /**