Browse Source

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.
pull/114/head
chrislusf 10 years ago
parent
commit
853701cb6b
  1. 7
      go/storage/needle_read_write.go
  2. 10
      go/topology/store_replicate.go
  3. 1
      go/weed/weed_server/volume_server_handlers_write.go

7
go/storage/needle_read_write.go

@ -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]

10
go/topology/store_replicate.go

@ -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
}

1
go/weed/weed_server/volume_server_handlers_write.go

@ -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 {

Loading…
Cancel
Save