在 hive 任务的执行过程中,可能出现 Too many counters 的异常。
如果执行引擎时 tez,则说明当前作业的 counters 数量超过 tez 默认的 counters 限制。
Exception: Too many counters: 2001 max=2000 at org.apache.tez.common.counters.Limits.checkCounters(Limits.java:88) at org.apache.tez.common.counters.Limits.incrCounters(Limits.java:95) at org.apache.tez.common.counters.AbstractCounterGroup.addCounter(AbstractCounterGroup.java:76)TEZ 默认 counters 设置
解决办法tez.counters.max 1200 Int value. Configuration to limit the counters per dag (AppMaster and Task). This can be used to limit the amount of memory being used in the app master to store the counters. Expert level setting. integer true tez.counters.max.groups 500 Int value. Configuration to limit the number of counter groups for a DAG. This can be used to limit the amount of memory being used in the app master to store the counters. Expert level setting. integer true
使用的系统有可能已经调大了 counters 的限制,但是个别作业还是会超过。那么通过 set 语句设置新的限制值。
set tez.counters.max=20000; set tez.counters.max.groups=10000;
如果还是报错,准确的方法是看 groups 的数量超出限制,还是 counters 超出限制? 设置不同的值。如示例中是 counters 的数量超出限制,只用调大 counters 的限制值。如果是 groups 的数量超出限制,则抛出 Too many counter groups: xxx max=xxx
如果日志不好找,或者不方便看,直接把 counters 和 groups 数量都增大 10 倍再试。



