首页 > 解决方案 > HIVE:插入查询失败并出现错误“java.lang.OutOfMemoryError:超出 GC 开销限制”

问题描述

我的 Hive 插入查询因以下错误而失败:java.lang.OutOfMemoryError:超出 GC 开销限制

table2 中的数据 = 1.7tb 查询:

set hive.exec.dynamic.partition.mode= nonstrict;set hive.exec.dynamic.partition=true;set mapreduce.map.memory.mb=15000;set mapreduce.map.java.opts=-Xmx9000m;set mapreduce.reduce.memory.mb=15000;set mapreduce.reduce.java.opts=-Xmx9000m;set hive.rpc.query.plan=true;
insert into database1.table1 PARTITION(trans_date) select * from database1.table2;

错误信息:在 1 中启动作业 1 由于没有 reduce 运算符,因此减少任务的数量设置为 0 失败:执行错误,从 org.apache.hadoop.hive.ql.exec.mr.MapRedTask 返回代码 -101。超出 GC 开销限制

集群信息:总内存:1.2TB 总 vcores:288 个节点总数:8 个节点版本:2.7.0-mapr-1808

请注意:我正在尝试将镶木地板格式的表 2 中的数据插入 ORC 格式的表 1。数据大小总共为 1.8TB。

标签: apache-sparkhadoophivemapr

解决方案


通过分区键添加分发应该可以解决问题:

insert into database1.table1 PARTITION(trans_date) select * from database1.table2
distribute by trans_date;

distribute by trans_date会触发reducer step,每个reducer都会处理单个partition,这样可以减少内存压力。当每个进程写入许多分区时,它会在内存中为 ORC 保留过多的缓冲区。

还可以考虑添加此设置来控制每个 reducer 将处理多少数据:

set hive.exec.reducers.bytes.per.reducer=67108864; --this is example only, reduce the figure to increase parallelism

推荐阅读