diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java index 53f0d0e..5ceb3d2 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java @@ -19,7 +19,6 @@ import java.io.File; import java.lang.reflect.Field; -import java.util.Random; import junit.framework.TestCase; @@ -32,6 +31,7 @@ import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.ObjectStore; import org.apache.hadoop.hive.ql.Driver; +import org.apache.hadoop.hive.ql.metadata.Hive; import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse; import org.apache.hadoop.hive.ql.session.SessionState; @@ -96,8 +96,9 @@ public void testVersionRestriction () throws Exception { // session creation should fail since the schema didn't get created try { SessionState.start(new CliSessionState(hiveConf)); - fail("Expected exception"); - } catch (RuntimeException re) { + Hive.get(hiveConf).getMSC(); + fail("An exception is expected since schema is not created."); + } catch (Exception re) { LOG.info("Exception in testVersionRestriction: " + re, re); String msg = HiveStringUtils.stringifyException(re); assertTrue("Expected 'Version information not found in metastore' in: " + msg, msg diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index 5e81e98..6cd63e9 100644 --- a/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ b/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -795,9 +795,6 @@ public void clearTestSideEffects() throws Exception { return; } - clearTablesCreatedDuringTests(); - clearKeysCreatedInTests(); - // allocate and initialize a new conf since a test can // modify conf by using 'set' commands conf = new HiveConf(Driver.class); @@ -805,6 +802,9 @@ public void clearTestSideEffects() throws Exception { // renew the metastore since the cluster type is unencrypted db = Hive.get(conf); // propagate new conf to meta store + clearTablesCreatedDuringTests(); + clearKeysCreatedInTests(); + setup.preTest(conf); } 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 9048d45..89b9896 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -176,7 +176,7 @@ private boolean isConnected = false; private URI metastoreUris[]; private final HiveMetaHookLoader hookLoader; - protected final HiveConf conf; + protected final HiveConf conf; // Keep a copy of HiveConf so if Session conf changes, we may need to get a new HMS client. protected boolean fastpath = false; private String tokenStrForm; private final boolean localMetaStore; @@ -202,9 +202,10 @@ public HiveMetaStoreClient(HiveConf conf, HiveMetaHookLoader hookLoader, Boolean this.hookLoader = hookLoader; if (conf == null) { - conf = new HiveConf(HiveMetaStoreClient.class); + this.conf = conf = new HiveConf(HiveMetaStoreClient.class); + } else { + this.conf = new HiveConf(conf); } - this.conf = conf; filterHook = loadFilterHooks(); fileMetadataBatchSize = HiveConf.getIntVar( conf, HiveConf.ConfVars.METASTORE_BATCH_RETRIEVE_OBJECTS_MAX); @@ -219,10 +220,10 @@ public HiveMetaStoreClient(HiveConf conf, HiveMetaHookLoader hookLoader, Boolean // instantiate the metastore server handler directly instead of connecting // through the network if (conf.getBoolVar(ConfVars.METASTORE_FASTPATH)) { - client = new HiveMetaStore.HMSHandler("hive client", conf, true); + client = new HiveMetaStore.HMSHandler("hive client", this.conf, true); fastpath = true; } else { - client = HiveMetaStore.newRetryingHMSHandler("hive client", conf, true); + client = HiveMetaStore.newRetryingHMSHandler("hive client", this.conf, true); } isConnected = true; snapshotActiveConf(); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java index 78bbb1f..32fe4fd 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java @@ -546,10 +546,6 @@ private static void start(SessionState startSs, boolean isAsync, LogHelper conso // Get the following out of the way when you start the session these take a // while and should be done when we start up. try { - // Hive object instance should be created with a copy of the conf object. If the conf is - // shared with SessionState, other parts of the code might update the config, but - // Hive.get(HiveConf) would not recognize the case when it needs refreshing - Hive.get(new HiveConf(startSs.conf)).getMSC(); UserGroupInformation sessionUGI = Utils.getUGI(); FileSystem.get(startSs.conf); @@ -575,10 +571,6 @@ private static void start(SessionState startSs, boolean isAsync, LogHelper conso } } catch (RuntimeException e) { throw e; - } catch (Hive.SchemaException e) { - RuntimeException ex = new RuntimeException(e.getMessage()); - ex.setStackTrace(new StackTraceElement[0]); - throw ex; } catch (Exception e) { // Catch-all due to some exec time dependencies on session state // that would cause ClassNoFoundException otherwise