您好,欢迎访问一九零五行业门户网

hadoop重启Namenode时,appTokens报FileNotFoundException

现象 报错如下 application application_1405852606905_0014 failed 3 times due to am container for appattempt_1405852606905_0014_000003 exited with exitcode: -1000 due to: remotetrace: java.io.filenotfoundexception: file does not exist: hdfs:
现象报错如下
application application_1405852606905_0014 failed 3 times due to am container for appattempt_1405852606905_0014_000003 exited with exitcode: -1000 due to: remotetrace: java.io.filenotfoundexception: file does not exist: hdfs://mycluster:8020/user/kpi/.staging/job_1405852606905_0014/apptokens at org.apache.hadoop.hdfs.distributedfilesystem.getfilestatus(distributedfilesystem.java:809)
同时注意到是因为每次重启nodemanager才发生。
首先用关键词“apptokens filenotfoundexception”在google和issue搜索没找到相关的问题。
猜测原因可能找不到的原因:1.客户端没上传成功 2.上传成功了,但后面不知道给谁删了
重现既然在网上找不到,尝试在测试环境重现这个问题,运行一个sleep job
cd /opt/cloudera/parcels/cdh/lib/hadoop-mapreduce;hadoop jar hadoop-mapreduce-client-*-tests.jar sleep -dmapred.job.queue.name=sleep -m5 -r5 -mt 60000 -rt 30000 -recordt 1000
重启nodemanage后会发现报错。
分析日志但发现找不到am的日志,哪里去了?我们的hadoop环境都配置了“日志聚集”(yarn.log-aggregation-enable),失败的任务就把日志删了(可能是bug),尝试关掉后,从crontainer日志找到am日志。
同时还可以看resourcemanager,namenode,hdfs审计日志(hdfs-audit.log)
从am日志可以看到第一次尝试好像是成功的,从hdfs审计日志发现了删除staging的目录
cmd=delete src=http://fatkun.com/user/kpi/.staging/job_1405852606905_0013
>到此可以确认目录是被删除了,导致后面的job失败,但谁删了这个目录?
继续搜索代码很多,需要定位一下那里操作.staging这个目录,确定谁删了这个目录。在issue搜索“staging delete”,看有没有相关的操作代码。同时阅读代码发现了org.apache.hadoop.mapreduce.v2.app.mrappmaster.cleanupstagingdir()方法,对照日志,可以确定是这个方法删除了staging目录。
public synchronized void stop() {...//这里判断了是不是am的最后一次尝试,如果是才清理 if(islastamretry) { cleanupstagingdir(); } ... }
这个逻辑还算正常, 继续找islastamretry是怎么来的
public void shutdownjob() {... //we are finishing cleanly so this is the last retry islastamretry = true; // stop all services // this will also send the final report to the resourcemanager log.info(calling stop for all the services); mrappmaster.this.stop();... }
发现调用了shutdownjob,会把islastamretry设置为true,调用shutdownjob是因为接收到jobfinishevent事件。
我们多了一些信息,偷懒在issue继续搜索一下,看有没有人解决了。
这次找到issue了,https://issues.apache.org/jira/browse/mapreduce-5086
阅读patch,发现之前忽略了rm报的一个错误。
org.apache.hadoop.yarn.exceptions.impl.pb.yarnremoteexceptionpbimpl: application doesn't exist in cache appattempt_1405852606905_0014_000001
结果重启nodemanager导致rm的appattempt cache数组删除,jobimpl返回了internalerror,am认为出错了就没必要重试了,直接置islastretry=true。
修改方式是加了一个状态,表明这是“rm重启”了(注意这里不是nodemanager重启,有一些关联),还可以继续重试。具体修改阅读patch https://issues.apache.org/jira/browse/mapreduce-5086
最后,由于patch修改的版本和我们用的版本不一致,还得需要用我们使用的版本依照它的思路改一遍。
原文地址:hadoop重启namenode时,apptokens报filenotfoundexception, 感谢原作者分享。
其它类似信息

推荐信息