Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-28534

Improve HMS Client Exception Handling for Hive-3.1.x

Log workAgile BoardRank to TopRank to BottomBulk Copy AttachmentsBulk Move AttachmentsAdd voteVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      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.

      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)
      

      The testing code that I used is as below:

      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);
              }
          }
      }
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            sercan.tekin Sercan Tekin Assign to me
            sercan.tekin Sercan Tekin

            Dates

              Created:
              Updated:

              Slack

                Issue deployment