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

Add TCP keepalive option for the hive jdbc driver

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.7.1
    • Fix Version/s: 1.1.0
    • Component/s: JDBC
    • Labels:
      None

      Description

      When issuing long running jdbc queries it is quite plausibe that due to stateful firewall rules connections may be dropped due to inactivity. Having the ability specify this as a jdbc property would help alleviate this issue when firewall connection inactivity timeouts are greater than the tcp keepalive time (default of 2 hrs).

      As a temporary workaround, one can use reflection on the jdbc connection to set this option:

          public static Connection getHiveConnection() {
              Connection hiveConnection = // create connection
              try {
                  Socket socket = getConnectionSocket( hiveConnection );
                  socket.setKeepAlive( true );
              } catch( SocketException e ) {
                  throw new RuntimeException( e );
              }
      
              return hiveConnection;
          }
      
          private static Socket getConnectionSocket( Connection connection ) {
              final Field fields[] = connection.getClass().getDeclaredFields();
              for( int i = 0; i < fields.length; ++i ) {
                  if( "transport".equals( fields[i].getName() ) ) {
                      try {
                          fields[i].setAccessible( true );
                          TSocket transport = (TSocket) fields[i].get( connection );
                          return transport.getSocket();
                      } catch( Exception e ) {
                          throw new RuntimeException( e );
                      }
                  }
              }
      
              return null;
          }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                btiernay Bob Tiernay
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: