简体   繁体   中英

java.lang.OutOfMemoryError: Java heap space error while executing Hive query

While running the Hive query from Hive Shell using TEZ execution engine, I am getting java.lang.OutOfMemoryError: Java heap space error in the logs, but the query is getting completed at the end.

I wanted to understand why am I getting this error in the logs, this query used to work without any issue in the past.

Does anyone have any clue or document which will help me understand the issue. I tried google it but it didn't help much.

Thanks in Advance for the Help!!!

ERROR : Status: Failed
ERROR : Vertex failed, vertexName=Map 3, vertexId=vertex_1622153507491_0145_1_02, diagnostics=[Task failed, taskId=task_1622153507491_0145_1_02_000006, diagnostics=[TaskAttempt 0 failed, info=[Error: Error while running task ( failure ) : java.lang.RuntimeException: Map operator initialization failed
        at org.apache.hadoop.hive.ql.exec.tez.MapRecordProcessor.init(MapRecordProcessor.java:361)
        at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:266)
        at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.run(TezProcessor.java:250)
        at org.apache.tez.runtime.LogicalIOProcessorRuntimeTask.run(LogicalIOProcessorRuntimeTask.java:374)
        at org.apache.tez.runtime.task.TaskRunner2Callable$1.run(TaskRunner2Callable.java:73)
        at org.apache.tez.runtime.task.TaskRunner2Callable$1.run(TaskRunner2Callable.java:61)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1730)
        at org.apache.tez.runtime.task.TaskRunner2Callable.callInternal(TaskRunner2Callable.java:61)
        at org.apache.tez.runtime.task.TaskRunner2Callable.callInternal(TaskRunner2Callable.java:37)
        at org.apache.tez.common.CallableWithNdc.call(CallableWithNdc.java:36)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:108)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:41)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Async Initialization failed. abortRequested=false
        at org.apache.hadoop.hive.ql.exec.Operator.completeInitialization(Operator.java:465)
        at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:399)
        at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:572)
        at org.apache.hadoop.hive.ql.exec.Operator.initializeChildren(Operator.java:524)
        at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:385)
        at org.apache.hadoop.hive.ql.exec.tez.MapRecordProcessor.init(MapRecordProcessor.java:342)
        ... 17 more
Caused by: java.lang.OutOfMemoryError: Java heap space
        at org.apache.hadoop.hive.serde2.WriteBuffers.nextBufferToWrite(WriteBuffers.java:261)
        at org.apache.hadoop.hive.serde2.WriteBuffers.write(WriteBuffers.java:237)
        at org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastBytesHashMapStore.addMore(VectorMapJoinFastBytesHashMapStore.java:539)
        at org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastBytesHashMap.add(VectorMapJoinFastBytesHashMap.java:101)
        at org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastStringCommon.adaptPutRow(VectorMapJoinFastStringCommon.java:59)
        at org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastStringHashMap.putRow(VectorMapJoinFastStringHashMap.java:37)
        at org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastTableContainer.putRow(VectorMapJoinFastTableContainer.java:183)
        at org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.VectorMapJoinFastHashTableLoader.load(VectorMapJoinFastHashTableLoader.java:130)
        at org.apache.hadoop.hive.ql.exec.MapJoinOperator.loadHashTableInternal(MapJoinOperator.java:344)
        at org.apache.hadoop.hive.ql.exec.MapJoinOperator.loadHashTable(MapJoinOperator.java:413)
        at org.apache.hadoop.hive.ql.exec.MapJoinOperator.lambda$initializeOp$0(MapJoinOperator.java:215)
        at org.apache.hadoop.hive.ql.exec.MapJoinOperator$$Lambda$27/55723736.call(Unknown Source)
        at org.apache.hadoop.hive.ql.exec.tez.ObjectCache.retrieve(ObjectCache.java:96)
        at org.apache.hadoop.hive.ql.exec.tez.ObjectCache$1.call(ObjectCache.java:113)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        ... 3 more

OOM Exception is in MapJoin operator when loading HashTable. Maybe alternative path without mapjoin have succeeded, this is why it is completed finally.

What you can do: try to increase mapper parallelism and if you got more mappers and id does not help, increase mapper memory. Check your current settings and change accordingly.

  1. Increase mapper parallelizm (this may not help if the reason actually is in too big table loaded into memory for mapjoin).
set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
set tez.grouping.max-size=32000000;  --decreasing max-size increases parallelism
set tez.grouping.min-size=32000;     --if you have small files less than min-size, mapper will additionally process other files 
  1. Increase mapper container size (check your current settings and increase accordingly). This is example only:
    set hive.tez.container.size=2048;  --container size in megabytes
    set hive.tez.java.opts=-Xmx1700m;  --set this 80% of hive.tez.container.size
  1. Map-side aggregation can lead to OOM, try to disable
    set hive.map.aggr=false; 
  1. Check your mapjoin settings, maybe smalltable size is set to too big, compare with container size which you set before: Hive Map-Join configuration mystery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM