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

HS2 leaks classloader due to `ReflectionUtils::CONSTRUCTOR_CACHE` with temporary functions + GenericUDF

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.3.4
    • 4.0.0-alpha-1
    • HiveServer2
    • None

    Description

      https://issues.apache.org/jira/browse/HIVE-10329 helped in moving away from hadoop's ReflectionUtils constructor cache issue (https://issues.apache.org/jira/browse/HADOOP-10513).

      However, there are corner cases where hadoop's ReflectionUtils is in use and this causes gradual build up of memory in HS2.

      I have observed this in Hive 2.3. But the codepath in master for this has not changed much.

      Easiest way to repro would be to add a temp function which extends GenericUDF. In FunctionRegistry::cloneGenericUDF, this would
      end up using org.apache.hadoop.util.ReflectionUtils.newInstance which in turn lands up in COSNTRUCTOR_CACHE of ReflectionUtils.

      CREATE TEMPORARY FUNCTION dummy AS 'com.hive.test.DummyGenericUDF' USING JAR 'file:///home/test/udf/dummy.jar';
      
      select dummy();
      
      	at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:107)
      	at org.apache.hadoop.hive.ql.exec.FunctionRegistry.cloneGenericUDF(FunctionRegistry.java:1353)
      	at org.apache.hadoop.hive.ql.exec.FunctionInfo.getGenericUDF(FunctionInfo.java:122)
      	at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory$DefaultExprProcessor.getXpathOrFuncExprNodeDesc(TypeCheckProcFactory.java:983)
      	at org.apache.hadoop.hive.ql.parse.TypeCheckProcFactory$DefaultExprProcessor.process(TypeCheckProcFactory.java:1359)
      	at org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher.dispatch(DefaultRuleDispatcher.java:90)
      	at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.dispatchAndReturn(DefaultGraphWalker.java:105)
      	at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.dispatch(DefaultGraphWalker.java:89)
      	at org.apache.hadoop.hive.ql.lib.ExpressionWalker.walk(ExpressionWalker.java:76)
      	at org.apache.hadoop.hive.ql.lib.DefaultGraphWalker.startWalking(DefaultGraphWalker.java:120)
      

      Note: Reflection based invocation of hadoop's ReflectionUtils::clear was removed in 2.x.

      Attachments

        1. HIVE-21971.1.patch
          5 kB
          Rajesh Balamohan
        2. HIVE-21971.2.patch
          5 kB
          Rajesh Balamohan
        3. HIVE-21971.3.patch
          5 kB
          Ashutosh Chauhan
        4. HIVE-21971.4.patch
          5 kB
          Ashutosh Chauhan
        5. HIVE-21971.5.patch
          5 kB
          Rajesh Balamohan

        Activity

          People

            rajesh.balamohan Rajesh Balamohan
            rajesh.balamohan Rajesh Balamohan
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: