dataengref errors

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.TezTask

Reproduced 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

  1. 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".
  2. 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.
  3. 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.

SettingDefaultNote
hive.tez.container.size-1in MB
hive.tez.java.optsnone

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 operators

Where the message comes from

Message template in the source: FAILED: Execution Error, return code %d from %s

References

Related errors

Last checked: