diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java index f00f08f..162eb96 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java @@ -330,8 +330,9 @@ public void run() { String rawStoreClassName = HiveConf.getVar(cachedStore.conf, HiveConf.ConfVars.METASTORE_CACHED_RAW_STORE_IMPL, ObjectStore.class.getName()); + RawStore rawStore = null; try { - RawStore rawStore = + rawStore = ((Class) MetaStoreUtils.getClass(rawStoreClassName)).newInstance(); rawStore.setConf(cachedStore.conf); List dbNames = rawStore.getAllDatabases(); @@ -356,6 +357,14 @@ public void run() { LOG.error("Updating CachedStore: error getting database names", e); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException("Cannot instantiate " + rawStoreClassName, e); + } finally { + try { + if (rawStore != null) { + rawStore.shutdown(); + } + } catch (Exception e) { + LOG.error("Error shutting down RawStore", e); + } } }