Home / Hive / Resources and memory
Hive: FAILED: Execution Error, return code 2 from TezTask or MapRedTask
FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.tez.TezTaskReproduced on Hive 4.2.1, · How
The query compiled but a task it launched failed. Return code 2 from TezTask or MapRedTask means the job failed at run time, and the cause is in the task logs. Other codes come from other tasks: in Hive 4 a dynamic partition limit, for example, shows up as return code 40000 from MoveTask with the reason appended.
Causes · Fixes · Reproduce · Source
Common causes
- Tasks ran out of memory (container killed or Java heap space).How to confirm: Open the failed application in the YARN UI or run yarn logs -applicationId <id> and search for "OutOfMemoryError" or "killed".
- Bad input data: a corrupt file, wrong format or a SerDe that cannot parse a row.How to confirm: The task log shows an exception from a reader or SerDe with a file path.
- Data skew: one reducer processes most of the data and times out or runs out of memory.How to confirm: One task runs far longer than the others in the Tez or YARN UI.
How to fix it
Read the task log of the first failed attempt and fix that error; the return code only says that the job failed.
For memory failures, raise the container size and Java heap together.
| Setting | Default | Note |
|---|---|---|
hive.tez.container.size | -1 | in MB |
hive.tez.java.opts | none |
Reproduce it
Triggered on Hive 4.2.1 in a local Docker container, using the SQL client:
CREATE TABLE IF NOT EXISTS repro_rows (a INT);
INSERT INTO repro_rows VALUES (1);
SET hive.fetch.task.conversion=none;
SELECT assert_true(a = 2) FROM repro_rows;Output:
Error: Error while compiling statement: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.tez.TezTask. Vertex failed, vertexName=Map 1, vertexId=vertex_1792721366912_0001_2_00, diagnostics=[Task failed, taskId=task_1792721366912_0001_2_00_000000, diagnostics=[TaskAttempt 0 failed, info=[Error: Node: baf386d98939/172.17.0.3 : Error while running task ( failure ) : attempt_1792721366912_0001_2_00_000000_0:java.lang.RuntimeException: java.lang.RuntimeException: Hive Runtime Error while closing operatorsWhere the message comes from
Executor.javainapache/hiveatrel/release-4.2.1- Message checked in Hive 4.2.1. The class is TezTask with the default engine and MapRedTask with hive.execution.engine=mr.
Message template in the source: FAILED: Execution Error, return code %d from %s