Sercan Tekin created HIVE-28534:
-----------------------------------

             Summary: Improve HMS Client Exception Handling for Hive-3
                 Key: HIVE-28534
                 URL: https://issues.apache.org/jira/browse/HIVE-28534
             Project: Hive
          Issue Type: Improvement
      Security Level: Public (Viewable by anyone)
          Components: Standalone Metastore
    Affects Versions: 3.1.3
            Reporter: Sercan Tekin
            Assignee: Sercan Tekin
             Fix For: 3.1.4


When the HMS client fails to connect to the server due to a 
*TTransportException*, there is no issue with error reporting. 

However, when the failure is caused by an *IOException*, the exception object, 
which is used for reporting purposes, remains null. As a result, it does not 
properly capture the root cause, and end-users encounter an unrelated NPE, 
masking the actual issue.

{code:java}
Exception in thread "main" java.lang.AssertionError: Unable to connect to HMS!
        at TestHMS.main(TestHMS.java:20)
Caused by: java.lang.NullPointerException
        at 
org.apache.hadoop.util.StringUtils.stringifyException(StringUtils.java:90)
        at 
org.apache.hadoop.hive.metastore.HiveMetaStoreClient.open(HiveMetaStoreClient.java:613)
        at 
org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:233)
        at 
org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:145)
        at TestHMS.main(TestHMS.java:13)
{code}

The testing code that I used is as below:
{code:java}
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
import org.apache.hadoop.hive.conf.HiveConf;
import java.util.List;

public class TestHMS {
    public static void main(String[] args) {
        String HOSTNAME = "<hostname>";
        HiveConf hiveConf = new HiveConf();
        hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://" + HOSTNAME 
+ ":9083");
        hiveConf.setBoolVar(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL, true);
        hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_METASTORE_USE_SSL, true);

        try (HiveMetaStoreClient client = new HiveMetaStoreClient(hiveConf)) {
            List<String> databases = client.getAllDatabases();
            System.out.println("Available databases:");
            for (String db : databases) {
                System.out.println(db);
            }
        } catch (Exception e) {
            throw new AssertionError("Unable to connect to HMS!", e);
        }
    }
}
{code}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to