Hive
  1. Hive
  2. HIVE-4406

Missing "/" or "/<dbname>" in hs2 jdbc uri switches mode to embedded mode

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.12.0
    • Component/s: HiveServer2
    • Labels:
      None
    • Release Note:
      patch available for review

      Description

      When the jdbc uri does not have a / or "/default" after the hostname:port, and the principal is specified, it ends up launching HS2 in embedded mode.

      This is because the parsing of uri in such case does not end up extracting the hostname.

      eg . "jdbc:hive2://<host>:<port>;principal=<>." results HS2 embedded mode getting used.
      "jdbc:hive2://<host>:<port>/;principal=<>" or "jdbc:hive2://<host>:<port>/default;principal=<>" results in it connecting to the standalone hive server 2.

      1. hive-4406.patch
        2 kB
        Anandha L Ranganathan

        Issue Links

          Activity

          Hide
          Anandha L Ranganathan added a comment -

          thejas , If you are not working, I would like to assign this bug to myself. Can anyone add me into the contributors list so that I can assign it myself.

          Show
          Anandha L Ranganathan added a comment - thejas , If you are not working, I would like to assign this bug to myself. Can anyone add me into the contributors list so that I can assign it myself.
          Hide
          Thejas M Nair added a comment -

          Anandha L Ranganathan I am not working on this. Please go ahead with this.

          Show
          Thejas M Nair added a comment - Anandha L Ranganathan I am not working on this. Please go ahead with this.
          Hide
          Thejas M Nair added a comment -

          I have updated the description, this is happening only when principal is specified (ie for secure mode).
          Anandha L Ranganathan If you don't have a secure cluster, then you can replace ";principal=<>" with any similar string. For example, you should be able to reproduce it using "jdbc:hive2://<host>:<port>;key1=val1."

          Do let me know if you have any questions. I am happy to help you with this.

          Show
          Thejas M Nair added a comment - I have updated the description, this is happening only when principal is specified (ie for secure mode). Anandha L Ranganathan If you don't have a secure cluster, then you can replace ";principal=<>" with any similar string. For example, you should be able to reproduce it using "jdbc:hive2://<host>:<port>;key1=val1." Do let me know if you have any questions. I am happy to help you with this.
          Hide
          Anandha L Ranganathan added a comment -

          thanks Thejas M Nair.

          I will let you know if I need more info.

          Show
          Anandha L Ranganathan added a comment - thanks Thejas M Nair . I will let you know if I need more info.
          Hide
          Anandha L Ranganathan added a comment -

          attached patch for this bug.

          Show
          Anandha L Ranganathan added a comment - attached patch for this bug.
          Show
          Anandha L Ranganathan added a comment - https://reviews.apache.org/r/10859/
          Hide
          Anandha L Ranganathan added a comment -

          Please review the changes.

          https://reviews.apache.org/r/10859/

          Show
          Anandha L Ranganathan added a comment - Please review the changes. https://reviews.apache.org/r/10859/
          Hide
          Anandha L Ranganathan added a comment -

          updated the patch with test case.

          Show
          Anandha L Ranganathan added a comment - updated the patch with test case.
          Hide
          Ashutosh Chauhan added a comment -

          +1

          Show
          Ashutosh Chauhan added a comment - +1
          Hide
          Thejas M Nair added a comment -

          Anandha L Ranganathan Sorry about the delay in reviewing this.
          This patch does not consider "hive2://abcd.com:10000;principal=hive/HiveServer2Host@YOUR-REALM.COM" as an invalid path.
          I think the better check is to check that the authority portion is not empty and host portion is null .

          To illustrate how the parsing happens for above jdbc uri -

                String ustr 
                = "hive2://abcd.com:10000;principal=hive/HiveServer2Host@YOUR-REALM.COM";
                URI uri = URI.create(ustr);
                System.out.println("uri " + uri);
                System.out.println("auth " + uri.getAuthority());
                System.out.println("uinfo " + uri.getUserInfo());
                System.out.println("host " + uri.getHost());
                System.out.println("path " + uri.getPath());
          

          has the following output -

          uri hive2://abcd.com:10000;principal=hive/HiveServer2Host@YOUR-REALM.COM
          auth abcd.com:10000;principal=hive
          uinfo null
          host null
          path /HiveServer2Host@YOUR-REALM.COM
          
          Show
          Thejas M Nair added a comment - Anandha L Ranganathan Sorry about the delay in reviewing this. This patch does not consider "hive2://abcd.com:10000;principal=hive/HiveServer2Host@YOUR-REALM.COM" as an invalid path. I think the better check is to check that the authority portion is not empty and host portion is null . To illustrate how the parsing happens for above jdbc uri - String ustr = "hive2: //abcd.com:10000;principal=hive/HiveServer2Host@YOUR-REALM.COM" ; URI uri = URI.create(ustr); System .out.println( "uri " + uri); System .out.println( "auth " + uri.getAuthority()); System .out.println( "uinfo " + uri.getUserInfo()); System .out.println( "host " + uri.getHost()); System .out.println( "path " + uri.getPath()); has the following output - uri hive2: //abcd.com:10000;principal=hive/HiveServer2Host@YOUR-REALM.COM auth abcd.com:10000;principal=hive uinfo null host null path /HiveServer2Host@YOUR-REALM.COM
          Hide
          Ashutosh Chauhan added a comment -

          Committed to trunk. Thanks, Anandha!

          Show
          Ashutosh Chauhan added a comment - Committed to trunk. Thanks, Anandha!
          Hide
          Ashutosh Chauhan added a comment -

          Aah.. sorry Thejas M Nair Missed your comment. I already committed it. Will you like to create a followup jira for this?

          Show
          Ashutosh Chauhan added a comment - Aah.. sorry Thejas M Nair Missed your comment. I already committed it. Will you like to create a followup jira for this?
          Hide
          Thejas M Nair added a comment -

          Ok, I will create a follow up jira for this.

          Show
          Thejas M Nair added a comment - Ok, I will create a follow up jira for this.
          Hide
          Thejas M Nair added a comment -

          Created follow up jira - HIVE-4802

          Show
          Thejas M Nair added a comment - Created follow up jira - HIVE-4802
          Hide
          Hudson added a comment -

          Integrated in Hive-trunk-h0.21 #2174 (See https://builds.apache.org/job/Hive-trunk-h0.21/2174/)
          HIVE-4406 : Missing / or /<dbname> in hs2 jdbc uri switches mode to embedded mode(Anandha Ranganathan via Ashutosh Chauhan) (Revision 1498673)

          Result = FAILURE
          hashutosh : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1498673
          Files :

          • /hive/trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java
          • /hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
          Show
          Hudson added a comment - Integrated in Hive-trunk-h0.21 #2174 (See https://builds.apache.org/job/Hive-trunk-h0.21/2174/ ) HIVE-4406 : Missing / or /<dbname> in hs2 jdbc uri switches mode to embedded mode(Anandha Ranganathan via Ashutosh Chauhan) (Revision 1498673) Result = FAILURE hashutosh : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1498673 Files : /hive/trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java /hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
          Hide
          Hudson added a comment -

          Integrated in Hive-trunk-hadoop2 #268 (See https://builds.apache.org/job/Hive-trunk-hadoop2/268/)
          HIVE-4406 : Missing / or /<dbname> in hs2 jdbc uri switches mode to embedded mode(Anandha Ranganathan via Ashutosh Chauhan) (Revision 1498673)

          Result = FAILURE
          hashutosh : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1498673
          Files :

          • /hive/trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java
          • /hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
          Show
          Hudson added a comment - Integrated in Hive-trunk-hadoop2 #268 (See https://builds.apache.org/job/Hive-trunk-hadoop2/268/ ) HIVE-4406 : Missing / or /<dbname> in hs2 jdbc uri switches mode to embedded mode(Anandha Ranganathan via Ashutosh Chauhan) (Revision 1498673) Result = FAILURE hashutosh : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1498673 Files : /hive/trunk/jdbc/src/java/org/apache/hive/jdbc/Utils.java /hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
          Hide
          Ashutosh Chauhan added a comment -

          This issue has been fixed and released as part of 0.12 release. If you find further issues, please create a new jira and link it to this one.

          Show
          Ashutosh Chauhan added a comment - This issue has been fixed and released as part of 0.12 release. If you find further issues, please create a new jira and link it to this one.

            People

            • Assignee:
              Anandha L Ranganathan
              Reporter:
              Thejas M Nair
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development