diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index b404603..194b905 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -273,7 +273,7 @@ METASTORECONNECTURLKEY("javax.jdo.option.ConnectionURL", "jdbc:derby:;databaseName=metastore_db;create=true"), // Number of attempts to retry connecting after there is a JDO datastore err - METASTOREATTEMPTS("hive.metastore.ds.retry.attempts", 1), + METASTOREATTEMPTS("hive.metastore.ds.retry.attempts", 0), // Number of miliseconds to wait between attepting METASTOREINTERVAL("hive.metastore.ds.retry.interval", 1000), // Whether to force reloading of the metastore configuration (including diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java index fb70589..13ddc65 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java @@ -51,7 +51,14 @@ protected RetryingHMSHandler(HiveConf hiveConf, String name) throws MetaExceptio // This has to be called before initializing the instance of HMSHandler init(); + //set "hive.metastore.ds.retry.attempts" to 5 because HMHandler.init() will + //not be retried by RetryingHMSHandler here, need to make sure it get retried + //at RetryingRawStore + HiveConf.setIntVar(this.hiveConf, HiveConf.ConfVars.METASTOREATTEMPTS, 5); this.base = (IHMSHandler) new HiveMetaStore.HMSHandler(name, hiveConf); + //set "hive.metastore.ds.retry.attempts" back to 0 to make sure there ie no + //conflict between retry from RetryingHMSHandler and RetryingRawStore + HiveConf.setIntVar(this.hiveConf, HiveConf.ConfVars.METASTOREATTEMPTS, 0); } public static IHMSHandler getProxy(HiveConf hiveConf, String name) throws MetaException { diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingRawStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingRawStore.java index 8f9f938..b6096a4 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingRawStore.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingRawStore.java @@ -77,8 +77,6 @@ public static RawStore getProxy(HiveConf hiveConf, Configuration conf, String ra private void init() throws MetaException { retryInterval = HiveConf.getIntVar(hiveConf, HiveConf.ConfVars.METASTOREINTERVAL); - retryLimit = HiveConf.getIntVar(hiveConf, - HiveConf.ConfVars.METASTOREATTEMPTS); // Using the hook on startup ensures that the hook always has priority // over settings in *.xml. The thread local conf needs to be used because at this point // it has already been initialized using hiveConf. @@ -96,6 +94,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl boolean gotNewConnectUrl = false; boolean reloadConf = HiveConf.getBoolVar(hiveConf, HiveConf.ConfVars.METASTOREFORCERELOADCONF); + //need to get up-to-date retryLimit from hiveConf because + //it may change due to HMSHanler.init() won't retried by + //RetryingHMSHander, and need to make sure it is retried + //by RetryingRawStrore + retryLimit = HiveConf.getIntVar(hiveConf, + HiveConf.ConfVars.METASTOREATTEMPTS); if (reloadConf) { MetaStoreInit.updateConnectionURL(hiveConf, getConf(), null, metaStoreInitData);