进行追加文件时出现AlreadyBeingCreatedException错误

堆栈信息大致如下:

org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException): Failed to create file [/secsight/log2//p0001] for [DFSClient_NONMAPREDUCE_200580206_1756] for client [192.168.10.117], because this file is already being created by [DFSClient_NONMAPREDUCE_-2109133545_2516] on [192.168.10.117]
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.recoverLeaseInternal(FSNamesystem.java:)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.appendFileInternal(FSNamesystem.java:)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.appendFileInt(FSNamesystem.java:)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.appendFile(FSNamesystem.java:)
at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.append(NameNodeRpcServer.java:)
at org.apache.hadoop.hdfs.server.namenode.AuthorizationProviderProxyClientProtocol.append(AuthorizationProviderProxyClientProtocol.java:)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.append(ClientNamenodeProtocolServerSideTranslatorPB.java:)
at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$.callBlockingMethod(ClientNamenodeProtocolProtos.java)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:)
at org.apache.hadoop.ipc.Server$Handler$.run(Server.java:)
at org.apache.hadoop.ipc.Server$Handler$.run(Server.java:)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:) at org.apache.hadoop.ipc.Client.call(Client.java:)
at org.apache.hadoop.ipc.Client.call(Client.java:)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:)
at com.sun.proxy.$Proxy9.append(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.append(ClientNamenodeProtocolTranslatorPB.java:)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:)
at java.lang.reflect.Method.invoke(Method.java:)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:)
at com.sun.proxy.$Proxy10.append(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient.callAppend(DFSClient.java:)
at org.apache.hadoop.hdfs.DFSClient.append(DFSClient.java:)
at org.apache.hadoop.hdfs.DFSClient.append(DFSClient.java:)
at org.apache.hadoop.hdfs.DistributedFileSystem$.doCall(DistributedFileSystem.java:)
at org.apache.hadoop.hdfs.DistributedFileSystem$.doCall(DistributedFileSystem.java:)
at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:)
at org.apache.hadoop.hdfs.DistributedFileSystem.append(DistributedFileSystem.java:)
at org.apache.hadoop.fs.FileSystem.append(FileSystem.java:)
at com.ultrapower.hdfs.HdfsUtils.appendFile(HdfsUtils.java:)
at com.ultrapower.secsight.Runner.lambda$main$(Runner.java:)
at java.lang.Thread.run(Thread.java:)

目前得到的可能原因:

  多进程进行同一文件的写入在HDFS中是可能引发这种错误的。

  hadoop 的dfs里边有个lease manager 维护了文件path -> lease和 DFSClient name -> lease -> path (多个) 的映射关系,我估计是这个lease的问题,看下是不是被close(),而未来的及释放的lease造成的。

可能引起该错误的代码:https://www.programcreek.com/java-api-examples/index.php?api=org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException

/** Test two consecutive appends on a file with a full block. */
@Test
public void testAppendTwice() throws Exception {
Configuration conf = new HdfsConfiguration();
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
final FileSystem fs1 = cluster.getFileSystem();
final FileSystem fs2 = AppendTestUtil.createHdfsWithDifferentUsername(conf);
try { final Path p = new Path("/testAppendTwice/foo");
final int len = << ;
final byte[] fileContents = AppendTestUtil.initBuffer(len); {
// create a new file with a full block.
FSDataOutputStream out = fs2.create(p, true, , (short), len);
out.write(fileContents, , len);
out.close();
} //1st append does not add any data so that the last block remains full
//and the last block in INodeFileUnderConstruction is a BlockInfo
//but not BlockInfoUnderConstruction.
fs2.append(p); //2nd append should get AlreadyBeingCreatedException
fs1.append(p);
Assert.fail();
} catch(RemoteException re) {
AppendTestUtil.LOG.info("Got an exception:", re);
Assert.assertEquals(AlreadyBeingCreatedException.class.getName(),
re.getClassName());
} finally {
fs2.close();
fs1.close();
cluster.shutdown();
}
}

https://issues.apache.org/jira/browse/HDFS-11367

https://issues.apache.org/jira/browse/HDFS-7203

【使用时发生的意外】HDFS 分布式写入问题 AlreadyBeingCreatedException的更多相关文章

  1. 【使用时发生的意外】file is not sufficiently replicated yet

    异常堆栈如下: -- ::, ERROR [com.ultrapower.secsight.util.HdfsUtil] - 追加写入文件失败! org.apache.hadoop.ipc.Remot ...

  2. HDFS 分布式写入问题 AlreadyBeingCreatedException

    进行追加文件时出现AlreadyBeingCreatedException错误 堆栈信息大致如下: org.apache.hadoop.ipc.RemoteException(org.apache.h ...

  3. ViewPager和SwipeRefreshLayout之间嵌套使用时发生"事件"冲突

    有时候我们会有一种需求,一个ViewPager有n个页面,每个页面是一个Fragment,在Fragment中使用了具有垂直滑动属性的控件,比如SwipeRefreshLayout!!! 这时二者之间 ...

  4. Webstorm使用时发生Page 'http://localhost:63340/n…tok/css/bootstrap.css.map' requested without authorization, you can copy URL and open it in browser to trust it.

    在使用webstorm编辑器开发时候,点击4处发生以下错误: Page 'http://localhost:63340/n…tok/css/bootstrap.css.map' requested w ...

  5. ElementUI的表单和vee-validate结合使用时发生冲突的解决

    在Vue项目中使用ElementUI表单时,同时又引入了vee-validate进行使用的时候,在浏览器上会出现这样的报错: [Vue warn]: The computed property &qu ...

  6. HttpWebRequest使用时发生阻塞的解决办法

    HttpWebRequest使用如下: 第一种:使用Using 释放资源 /// <summary> /// Http Get请求返回数据 /// </summary> /// ...

  7. 大数据基础总结---HDFS分布式文件系统

    HDFS分布式文件系统 文件系统的基本概述 文件系统定义:文件系统是一种存储和组织计算机数据的方法,它使得对其访问和查找变得容易. 文件名:在文件系统中,文件名是用于定位存储位置. 元数据(Metad ...

  8. Hadoop HDFS分布式文件系统设计要点与架构

      Hadoop HDFS分布式文件系统设计要点与架构     Hadoop简介:一个分布式系统基础架构,由Apache基金会开发.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群 ...

  9. 通过Thrift访问HDFS分布式文件系统的性能瓶颈分析

    通过Thrift访问HDFS分布式文件系统的性能瓶颈分析 引言 Hadoop提供的HDFS布式文件存储系统,提供了基于thrift的客户端访问支持,但是因为Thrift自身的访问特点,在高并发的访问情 ...

随机推荐

  1. js监听文本框变化事件

    用js有两种写法: 法一: <!DOCTYPE HTMl> <html> <head> <title> new document </title& ...

  2. 原生sqlServer数据库连接

    package tj.test.demo; import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Sta ...

  3. dp + 状态压缩 - Codeforces 580D Kefa and Dishes

    Kefa and Dishes Problem's Link Mean: 菜单上有n道菜,需要点m道.每道菜的美味值为ai. 有k个规则,每个规则:在吃完第xi道菜后接着吃yi可以多获得vi的美味值. ...

  4. zend Studio10.6.2 下载

    http://www.th7.cn/Program/php/201409/286788.shtml

  5. TensorFlow基础笔记(4) Tensor Transformation

    https://segmentfault.com/a/1190000008793389 抽取 tf.slice(input_, begin, size, name=None):按照指定的下标范围抽取连 ...

  6. 【BZOJ】1649: [Usaco2006 Dec]Cow Roller Coaster(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1649 又是题解... 设f[i][j]表示费用i长度j得到的最大乐趣 f[i][end[a]]=ma ...

  7. mysql 分页sql

    -- pageSize=3 pageIndex total=7 -- 开始行号 startRowNum=(pageIndex-1)*pageSize+1; -- 结束行号 endRowNum=page ...

  8. MyBatis 3.2.6插入时候获取自增主键方法

    MyBatis 3.2.6插入时候获取自增主键方法有二 以MySQL5.5为例: 方法1: <insert id="insert" parameterType="P ...

  9. 学习《深入理解C#》—— 可空类型、可选参数和默认值 (第一章1.3)

    目录 C#可空类型 C# 可选参数和默认值 C# 可空类型 在日常生活中,相信大家都离不开手机,低头族啊!哈哈... 假如手机厂商生产了一款新手机,暂时还未定价,在C#1中我们该怎么做呢? 常见的解决 ...

  10. Python Scrapy 自动爬虫注意细节(3)

    一.对指定页面爬取 yield Request(url, meta={'cookiejar': response.meta['cookiejar']}, callback=self.parse_url ...