This is an automated email from the ASF dual-hosted git repository. dkuzmenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push: new 01cc7ca6723 HIVE-29078: RuntimeException: Null when starting standalone HMS (#5956) 01cc7ca6723 is described below commit 01cc7ca672320447b20bc9883e2598d9fb34fc10 Author: dengzh <dengzhhu...@gmail.com> AuthorDate: Sat Jul 12 02:18:24 2025 +0800 HIVE-29078: RuntimeException: Null when starting standalone HMS (#5956) --- .../java/org/apache/hadoop/hive/conf/HiveConf.java | 34 ++++++++++++++++------ .../{hivemetastore-site.xml => metastore-site.xml} | 0 .../{hivemetastore-site.xml => metastore-site.xml} | 6 ++-- .../{hivemetastore-site.xml => metastore-site.xml} | 4 +-- .../hive/metastore/TestServerSpecificConfig.java | 8 ++--- .../org/apache/hive/jdbc/TestRestrictedList.java | 6 ++-- .../apache/hive/testutils/HiveTestEnvSetup.java | 2 +- .../hadoop/hive/metastore/HiveMetaStore.java | 1 + .../hive/metastore/PersistenceManagerProvider.java | 1 - .../hive/metastore/conf/TestMetastoreConf.java | 4 +-- 10 files changed, 41 insertions(+), 25 deletions(-) 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 71ae2b0222d..b99302893fc 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -92,7 +92,8 @@ public class HiveConf extends Configuration { private static boolean loadHiveServer2Config = false; private static URL hiveDefaultURL = null; private static URL hiveSiteURL = null; - private static URL hivemetastoreSiteUrl = null; + private static URL hiveMetastoreSiteUrl = null; + private static URL metastoreSiteUrl = null; private static URL hiveServer2SiteUrl = null; private static byte[] confVarByteArray = null; @@ -198,8 +199,9 @@ public static class EncoderDecoderFactory { // Look for hive-site.xml on the CLASSPATH and log its location if found. hiveSiteURL = findConfigFile(classLoader, "hive-site.xml", true); - hivemetastoreSiteUrl = findConfigFile(classLoader, "hivemetastore-site.xml", false); - hiveServer2SiteUrl = findConfigFile(classLoader, "hiveserver2-site.xml", false); + hiveMetastoreSiteUrl = findConfigFile(classLoader, "hivemetastore-site.xml", true); + hiveServer2SiteUrl = findConfigFile(classLoader, "hiveserver2-site.xml", true); + metastoreSiteUrl = findConfigFile(classLoader, "metastore-site.xml", true); for (ConfVars confVar : ConfVars.values()) { vars.put(confVar.varname, confVar); @@ -6617,15 +6619,20 @@ private void initialize(Class<?> cls) { setLoadMetastoreConfig(true); } - // load hivemetastore-site.xml if this is metastore and file exists - if (isLoadMetastoreConfig() && hivemetastoreSiteUrl != null) { - addResource(hivemetastoreSiteUrl); + // load the legacy hivemetastore-site.xml and metastore-site.xml if this is metastore and file exists + if (isLoadMetastoreConfig()) { + if (hiveMetastoreSiteUrl != null) { + addResource(hiveMetastoreSiteUrl); + } + if (metastoreSiteUrl != null) { + addResource(metastoreSiteUrl); + } } // load hiveserver2-site.xml if this is hiveserver2 and file exists // metastore can be embedded within hiveserver2, in such cases // the conf params in hiveserver2-site.xml will override whats defined - // in hivemetastore-site.xml + // in hivemetastore-site.xml/metastore-site.xml if (isLoadHiveServer2Config()) { // set the hardcoded value first, so anything in hiveserver2-site.xml can override it set(ConfVars.METASTORE_CLIENT_CAPABILITIES.varname, "EXTWRITE,EXTREAD,HIVEBUCKET2,HIVEFULLACIDREAD," @@ -7025,16 +7032,25 @@ public static void setHiveSiteLocation(URL location) { hiveSiteURL = location; } + /** + * @deprecated use setMetastoreSiteLocation(URL location) + * @param location the Metastore property source + */ + @Deprecated public static void setHivemetastoreSiteUrl(URL location) { - hivemetastoreSiteUrl = location; + setMetastoreSiteLocation(location); } public static URL getHiveSiteLocation() { return hiveSiteURL; } + public static void setMetastoreSiteLocation(URL location) { + metastoreSiteUrl = location; + } + public static URL getMetastoreSiteLocation() { - return hivemetastoreSiteUrl; + return metastoreSiteUrl; } public static URL getHiveServer2SiteLocation() { diff --git a/data/conf/llap/hivemetastore-site.xml b/data/conf/llap/metastore-site.xml similarity index 100% rename from data/conf/llap/hivemetastore-site.xml rename to data/conf/llap/metastore-site.xml diff --git a/data/conf/hivemetastore-site.xml b/data/conf/metastore-site.xml similarity index 92% rename from data/conf/hivemetastore-site.xml rename to data/conf/metastore-site.xml index e64fddf264f..d314d299bf0 100644 --- a/data/conf/hivemetastore-site.xml +++ b/data/conf/metastore-site.xml @@ -22,19 +22,19 @@ <property> <name>hive.dummyparam.test.server.specific.config.override</name> - <value>from.hivemetastore-site.xml</value> + <value>from.metastore-site.xml</value> <description>Using dummy param to test server specific configuration</description> </property> <property> <name>hive.dummyparam.test.server.specific.config.metastoresite</name> - <value>from.hivemetastore-site.xml</value> + <value>from.metastore-site.xml</value> <description>Using dummy param to test server specific configuration</description> </property> <property> <name>hive.conf.restricted.list</name> - <value>from.hivemetastore-site.xml</value> + <value>from.metastore-site.xml</value> <description>Using property defined in HiveConf.ConfVars to test System property overriding</description> </property> diff --git a/data/conf/rlist/hivemetastore-site.xml b/data/conf/rlist/metastore-site.xml similarity index 93% rename from data/conf/rlist/hivemetastore-site.xml rename to data/conf/rlist/metastore-site.xml index 8fdddff1a17..fb9887e4192 100644 --- a/data/conf/rlist/hivemetastore-site.xml +++ b/data/conf/rlist/metastore-site.xml @@ -22,13 +22,13 @@ <property> <name>hive.dummyparam.test.server.specific.config.override</name> - <value>from.hivemetastore-site.xml</value> + <value>from.metastore-site.xml</value> <description>Using dummy param to test server specific configuration</description> </property> <property> <name>hive.dummyparam.test.server.specific.config.metastoresite</name> - <value>from.hivemetastore-site.xml</value> + <value>from.metastore-site.xml</value> <description>Using dummy param to test server specific configuration</description> </property> diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestServerSpecificConfig.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestServerSpecificConfig.java index e2fbf045027..5690e7322b7 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestServerSpecificConfig.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestServerSpecificConfig.java @@ -56,10 +56,10 @@ public void testServerConfigsEmbeddedMetastore() throws IOException, Throwable { // check config properties expected with embedded metastore client assertTrue(HiveConf.isLoadMetastoreConfig()); - assertEquals("from.hivemetastore-site.xml", + assertEquals("from.metastore-site.xml", conf.get("hive.dummyparam.test.server.specific.config.override")); - assertEquals("from.hivemetastore-site.xml", + assertEquals("from.metastore-site.xml", conf.get("hive.dummyparam.test.server.specific.config.metastoresite")); assertEquals("from.hive-site.xml", @@ -74,7 +74,7 @@ public void testServerConfigsEmbeddedMetastore() throws IOException, Throwable { conf = new HiveConf(); verifyHS2ConfParams(conf); - assertEquals("from.hivemetastore-site.xml", + assertEquals("from.metastore-site.xml", conf.get("hive.dummyparam.test.server.specific.config.metastoresite")); } @@ -131,7 +131,7 @@ public void resetDefaults() throws SecurityException, IllegalArgumentException, } /** - * Test to ensure that HiveConf does not try to load hivemetastore-site.xml, + * Test to ensure that HiveConf does not try to load metastore-site.xml, * when remote metastore is used. * * @throws IOException diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java index b4b80d6f8cf..0eca3a4f3c0 100644 --- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java +++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java @@ -54,8 +54,8 @@ public static void startServices() throws Exception { HiveConf.setHiveSiteLocation( new URL("file://" + new File(confDir).toURI().getPath() + "/hive-site.xml")); System.out.println("Setting hive-site: " + HiveConf.getHiveSiteLocation()); - HiveConf.setHivemetastoreSiteUrl( - new URL("file://" + new File(confDir).toURI().getPath() + "/hivemetastore-site.xml")); + HiveConf.setMetastoreSiteLocation( + new URL("file://" + new File(confDir).toURI().getPath() + "/metastore-site.xml")); System.out.println("Setting hive-site: " + HiveConf.getHiveSiteLocation()); hiveConf = new HiveConf(); @@ -121,7 +121,7 @@ public static void stopServices() throws Exception { if (miniHS2 != null && miniHS2.isStarted()) { miniHS2.stop(); } - HiveConf.setHivemetastoreSiteUrl(oldHiveMetastoreSiteURL); + HiveConf.setMetastoreSiteLocation(oldHiveMetastoreSiteURL); HiveConf.setHiveSiteLocation(oldHiveSiteURL); } diff --git a/ql/src/test/org/apache/hive/testutils/HiveTestEnvSetup.java b/ql/src/test/org/apache/hive/testutils/HiveTestEnvSetup.java index 8c5a92416af..1db11599fe0 100644 --- a/ql/src/test/org/apache/hive/testutils/HiveTestEnvSetup.java +++ b/ql/src/test/org/apache/hive/testutils/HiveTestEnvSetup.java @@ -150,7 +150,7 @@ public void beforeClass(HiveTestEnvContext ctx) throws Exception { FileUtils.copyDirectory(new File(DATA_DIR + "/conf/tez"), confFolder); HiveConf.setHiveSiteLocation(new File(confFolder, "hive-site.xml").toURI().toURL()); - HiveConf.setHivemetastoreSiteUrl(new File(confFolder, "hivemetastore-site.xml").toURI().toURL()); + HiveConf.setMetastoreSiteLocation(new File(confFolder, "metastore-site.xml").toURI().toURL()); // FIXME: hiveServer2SiteUrl is not settable? ctx.hiveConf = new HiveConf(IDriver.class); diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 23cc6e8420c..35b76e1e967 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -267,6 +267,7 @@ public static void main(String[] args) throws Throwable { //for metastore process, all metastore call should be embedded metastore call. conf.set(ConfVars.THRIFT_URIS.getHiveName(), ""); + conf.set(ConfVars.THRIFT_URIS.getVarname(), ""); // Add shutdown hook. shutdownHookMgr.addShutdownHook(() -> { diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java index daaed16d947..bf99745cc7d 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java @@ -653,7 +653,6 @@ private static <T> T retry(Supplier<T> s) { LOG.warn("Exception retry limit reached, not retrying any longer.", e); } else { LOG.debug("Non-retriable exception.", e); - break; } ex = e; } diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java index 1bed2c00de5..24af86f4061 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java @@ -219,7 +219,7 @@ public void readHiveSiteWithHiveHomeDir() throws IOException { @Test public void readHiveMetastoreSiteWithHiveConfDir() throws IOException { - createConfFile("hivemetastore-site.xml", false, "HIVE_CONF_DIR", instaMap( + createConfFile("metastore-site.xml", false, "HIVE_CONF_DIR", instaMap( "test.double", "1.8" )); conf = MetastoreConf.newMetastoreConf(); @@ -229,7 +229,7 @@ public void readHiveMetastoreSiteWithHiveConfDir() throws IOException { @Test public void readHiveMetastoreSiteWithHiveHomeDir() throws IOException { - createConfFile("hivemetastore-site.xml", true, "HIVE_HOME", instaMap( + createConfFile("metastore-site.xml", true, "HIVE_HOME", instaMap( "test.bool", "false" )); conf = MetastoreConf.newMetastoreConf();