Avoid wrong way to delete on replication failure

Avoid wrong way to delete on replication failure. This deletion has bug
to write. The better fix is not to use the deletion on failure at all.
This commit is contained in:
chrislusf 2015-03-09 00:34:26 -07:00
parent 9d8a6d2562
commit 853701cb6b
3 changed files with 7 additions and 11 deletions

View file

@ -76,6 +76,8 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, err error) {
if n.HasTtl() {
n.Size = n.Size + TtlBytesLength
}
} else {
n.Size = 0
}
size = n.DataSize
util.Uint32toBytes(header[12:16], n.Size)
@ -185,6 +187,11 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) {
if index < lenBytes {
n.DataSize = util.BytesToUint32(bytes[index : index+4])
index = index + 4
if int(n.DataSize)+index > lenBytes {
// this if clause is due to bug #87 and #93, fixed in v0.69
// remove this clause later
return
}
n.Data = bytes[index : index+int(n.DataSize)]
index = index + int(n.DataSize)
n.Flags = bytes[index]

View file

@ -45,16 +45,6 @@ func ReplicatedWrite(masterNode string, s *storage.Store,
}
}
}
if errorStatus != "" {
if _, err = s.Delete(volumeId, needle); err != nil {
errorStatus += "\nCannot delete " + strconv.FormatUint(needle.Id, 10) + " from " +
volumeId.String() + ": " + err.Error()
} else {
distributedOperation(masterNode, s, volumeId, func(location operation.Location) bool {
return nil == util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate", jwt)
})
}
}
size = ret
return
}

View file

@ -67,7 +67,6 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
return
}
n.Size = 0
ret := topology.ReplicatedDelete(vs.GetMasterNode(), vs.store, volumeId, n, r)
if ret != 0 {