Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

append call failed with ERROR_APPLICATION (org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException) #61

Closed
24 opened this issue Nov 30, 2016 · 8 comments

Comments

@24
Copy link

24 commented Nov 30, 2016

hi colinmarc :

Thank you for your open source

I have a problem when for append content to hdfs
example:

writer, err := client.Create(fileName)	
writer.Close()

for i := 0; i < 10000; i++ {
		writer, err := client.Append(fileName)
                n, err := writer.Write([]byte("\nbar"))
		writer.Close()
}

then nameNode log error:

2016-12-01 01:42:20,828 INFO org.apache.hadoop.ipc.Server: IPC Server handler 7 on 9000,
 call org.apache.hadoop.hdfs.protocol.ClientProtocol.append from 192.168.10.209:60494
 Call#2 Retry#-1: org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException: 
Failed to APPEND_FILE /tmp/x/15.txt for go-hdfs-MHz41XTUfY3nheHd on 192.168.10.209 because this file lease is currently owned
 by go-hdfs-sm0fZSGAQA0uvyqR on 192.168.10.209

and golang error:

file_writer_test.go:323: err: append /tmp/ab/15.txt: append call failed with 
ERROR_APPLICATION (org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException)

hadoop version : 2.7.3
Single Node Cluster

hdfs-site.xml

<configuration> 
    <property>
      <name>dfs.replication</name>
      <value>1</value>
     </property>
  <property>
        <name>dfs.webhdfs.enabled</name>
        <value>true</value>
    </property>
  <property>
      <name>dfs.permissions.enabled</name>
      <value>false</value>
    </property>
 </configuration> 

when i use script

#!/bin/bash
for i in {1..10000}
do
	hdfs="hdfs dfs -appendToFile ~/tmp/1 /data/2016-12-01/2016-12-01.tmp1"
	eval ${hdfs}
   echo "Welcome $i times"
done

this way ok . no error

I don't know how to solve this problem .
do you have any idea ?
thanks

@colinmarc
Copy link
Owner

Huh - that certainly seems like a bug. Thanks for the report! If you have a chance to submit a test case for this behavior, that would be much appreciated.

@fnxnet
Copy link

fnxnet commented Feb 6, 2017

Any news on this issue?

1 similar comment
@argpass
Copy link

argpass commented Feb 25, 2017

Any news on this issue?

@argpass
Copy link

argpass commented Feb 25, 2017

I have fixed it:
block_write_stream.go, in method makePacket

func (s *blockWriteStream) makePacket() outboundPacket {
	packetLength := outboundPacketSize
	if s.buf.Len() < outboundPacketSize {
		packetLength = s.buf.Len()
	}
        // fill last chunk's margin with an individual packet
	marginSize := outboundChunkSize - (int(s.offset) % outboundChunkSize)
	if marginSize > 0 && packetLength > marginSize {
		packetLength = marginSize
	}
......

@colinmarc
Copy link
Owner

@zkchen310 - thanks very much for figuring that out! Sorry for any delinquency on my part. :)

@zhaijian
Copy link

hi,colinmarc:

  • i check the newest code,the git version is d961456,
  • but i encountered the same problem:
  • when i first append,the err is "addBlock call failed with ERROR_APPLICATION (org.apache.hadoop.hdfs.server.namenode.NotReplicatedYetException)",and i append again, the err is "append call failed with ERROR_APPLICATION (org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException)"

code:

    nameServer := flag.String("nameserver", "", "The HDFS Name Node Address")
user := flag.String("user", "", "The HDFS Visitor User")
hdfsPath := flag.String("hdfsPath", "", "The HDFS  Which Will Write To HDFS")
createFlag := flag.String("create", "", "create file flag")
flag.Parse()
mockStr := fmt.Sprintf(time.Now().String())
client, err := hdfs.NewForUser(*nameServer, *user)
utee.Chk(err)
defer client.Close()
if *createFlag != "" {
	w, err := client.Create(*hdfsPath)
	if err != nil {
		log.Println("CreateFile err", err)
	}
	_, err = w.Write([]byte(mockStr))
	log.Println("write err", err)
	w.Close()
	return
}

w, err := client.Append(*hdfsPath)
//defer w.Close()
if err != nil {
	log.Println("append err", err)
	return
}
_, err = w.Write([]byte(mockStr))
log.Println("write err", err)
w.Close()

any advice? thank you!

@Revaapriyan
Copy link

Revaapriyan commented Dec 17, 2018

I'm facing this issue now. Can anyone give me some solution? I log my data, which flows in through a TCP connection, into the relevant file (opened in append mode) in HDFS.

I will get name whenever a new connection is established

hdfl, err := hdcli.Append(path.Join(hfdsDir, name+".txt"))
if os.IsNotExist(err) {
	log.Println("File doesnot exist, creating...")
	err = hdcli.CreateEmptyFile(path.Join(hfdsDir, name+".jsonl"))
	if err != nil {
		log.Println("Error creating the file:", err)
	}
	hdfl, err = hdcli.Append(path.Join(hfdsDir, name+".jsonl"))
} else if err != nil {
	log.Println("Error opening the file with append:", err)
}
defer hdfl.Close()
hdg := json.NewEncoder(hdfl)
for{
    msg,err = con.Read()
    if err!=nil{
        return
    }
    hdg.Encode(msg)
    hdfl.Flush()
}

@mountainhua
Copy link

this issue is still exist in v2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants