79

I am getting:

FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask

While trying to make a copy of a partitioned table using the commands in the hive console:

CREATE TABLE copy_table_name LIKE table_name;
INSERT OVERWRITE TABLE copy_table_name PARTITION(day) SELECT * FROM table_name;

I initially got some semantic analysis errors and had to set:

set hive.exec.dynamic.partition=true
set hive.exec.dynamic.partition.mode=nonstrict

Although I'm not sure what the above properties do?

Full ouput from hive console:

Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks determined at compile time: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapred.reduce.tasks=<number>
Starting Job = job_201206191101_4557, Tracking URL = http://jobtracker:50030/jobdetails.jsp?jobid=job_201206191101_4557
Kill Command = /usr/lib/hadoop/bin/hadoop job  -Dmapred.job.tracker=master:8021 -kill job_201206191101_4557
2012-06-25 09:53:05,826 Stage-1 map = 0%,  reduce = 0%
2012-06-25 09:53:53,044 Stage-1 map = 100%,  reduce = 100%
Ended Job = job_201206191101_4557 with errors
FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask
Gyanendra Dwivedi
  • 5,511
  • 2
  • 27
  • 53
nickponline
  • 25,354
  • 32
  • 99
  • 167
  • I've seen this when querying a hive table that hasn't had compaction recently. Try - alter table xyz compact 'MAJOR'; – DaveEdelstein Apr 15 '16 at 14:19
  • 1
    BTW set hive.auto.convert.join=false; Fixed the issue in my case... – Chris Mar 08 '17 at 16:36
  • In my case, this not-very-useful error message was due to running hive from a folder where I didn't have write permission to. switching the directory fixed the issue. – Zahra Oct 23 '17 at 18:35
  • I have faced the same issue, And i have noticed that same query running from Impala but not from Hive. Then i have gone through YARN Container logs and i realized that ***Name node is in safe mode***. – Manindar Nov 29 '17 at 09:54

11 Answers11

128

That's not the real error, here's how to find it:

Go to the hadoop jobtracker web-dashboard, find the hive mapreduce jobs that failed and look at the logs of the failed tasks. That will show you the real error.

The console output errors are useless, largely beause it doesn't have a view of the individual jobs/tasks to pull the real errors (there could be errors in multiple tasks)

starball
  • 20,030
  • 7
  • 43
  • 238
Matthew Rathbone
  • 8,144
  • 7
  • 49
  • 79
  • Hi @Matthew, same happened here. I ran it in Talend which gave me this error but in HIVE console, it worked fine. Any clue how may I resume. Thanks – Kanav Sharma Sep 05 '17 at 14:25
  • 8
    Is there some way to view the logs without using the web-dashboard? – Daniel Watrous Feb 08 '19 at 18:21
  • Lol, no. You'd think there would be, but no there isn't. Amazon's EMR has all the logs to go S3, so you can just get them from the S3 bucket. It may be that yarn puts them on HDFS by default, but I'm not sure how to figure that out. – Matthew Rathbone May 15 '20 at 17:32
21

I know I am 3 years late on this thread, however still providing my 2 cents for similar cases in future.

I recently faced the same issue/error in my cluster. The JOB would always get to some 80%+ reduction and fail with the same error, with nothing to go on in the execution logs either. Upon multiple iterations and research I found that among the plethora of files getting loaded some were non-compliant with the structure provided for the base table(table being used to insert data into partitioned table).

Point to be noted here is whenever I executed a select query for a particular value in the partitioning column or created a static partition it worked fine as in that case error records were being skipped.

TL;DR: Check the incoming data/files for inconsistency in the structuring as HIVE follows Schema-On-Read philosophy.

user3032283
  • 373
  • 2
  • 10
4

Adding some information here, as it took me awhile to find the hadoop jobtracker web-dashboard in HDInsight (Azure's Hadoop), and a colleague finally showed me where it was. There is a shortcut on the head node called "Hadoop Yarn Status" which is just a link to a local http page (http://headnodehost:9014/cluster in my case). When opened the dashboard looked like this:

enter image description here

In that dashboard you can find your failed application, and then after clicking into it you can look at the logs of the individual map and reduce jobs.

In my case it seemed to still be running out of memory in the reducers, even though I had cranked the memory in the configuration already. For some reason it was not surfacing the "java outofmemory" errors I got earlier though.

Mike Wise
  • 22,131
  • 8
  • 81
  • 104
3

The top answer is right, that the error code doesn't give you much info. One of the common causes that we saw in our team for this error code was when the query was not optimized well. A known reason was when we do an inner join with the left side table magnitudes bigger than the table on right side. Swapping these tables would usually do the trick in such cases.

2

I removed the _SUCCESS file from the EMR output path in S3 and it worked fine.

2

I was also facing same error when I was inserting the data into HIVE external table which was pointing to Elastic search cluster.

I replaced the older JAR elasticsearch-hadoop-2.0.0.RC1.jar to elasticsearch-hadoop-5.6.0.jar, and everything worked fine.

My Suggestion is please use the specific JAR as per the elastic search version. Don't use older JARs if you are using newer version of elastic search.

Thanks to this post Hive- Elasticsearch Write Operation #409

Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90
  • 1
    You provided us with a specific scenario of the same issue but got a downvote, it doesn't make sense. I will give you upvote. – Eugene Oct 16 '19 at 07:27
2

Received this error when joining two tables. And one table is large in size and another table is small, which could fit into disk memory. In such a case, use

set hive.auto.convert.join = false

This might help to get rid of the above error. For more detail on this issue please refer to the below threads

  1. Hive Map-Join configuration mystery
  2. Hive.auto.convert.join = true what is the significance of this?
Ransaka Ravihara
  • 1,786
  • 1
  • 13
  • 30
1

Even I faced the same issue - when checked on dashboard I found following Error. As the data was coming through Flume and had interrupted in between due to which may be there was inconsistency in few files.

Caused by: org.apache.hadoop.hive.serde2.SerDeException: org.codehaus.jackson.JsonParseException: Unexpected end-of-input within/between OBJECT entries

Running on fewer files it worked. Format consistency was the reason in my case.

Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90
  • I got the same problem. But m not able to find the log file. Could you please help me out in finding the log file? – Jon Andrews Mar 25 '17 at 06:35
1

I faced the same issue because I didn't have permission to query the database I was trying to.

In the case you don't have permission to query the table/database, besides the Return Code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask error, you will see that in Cloudera Manager is not even registering your query.

Ignacio Alorre
  • 7,307
  • 8
  • 57
  • 94
1

In my case, the solution was adding more RAM Memory to the Virtual Machines. Sometimes code 2 means that Map and Reduce nodes do not have enough memory. Another option could be changing the properties "mapreduce.map.memory.mb" y "mapreduce.reduce.memory.mb" in the mapred-site.xml file.

CGG
  • 253
  • 1
  • 11
  • 22
0

I got the same error while creating the hive table in beeline and then tried to create through spark-shell which thrown actual error. In my case error was with disk space quota for hdfs directory.

org.apache.hadoop.ipc.RemoteException: The DiskSpace quota of /user/hive/warehouse/XXX_XX.db is exceeded: quota = 6597069766656 B = 6 TB but diskspace consumed = 6597493381629 B = 6.00 TB

Nagaraj Vittal
  • 881
  • 13
  • 26