Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Avoid wrong way to delete on replication failure

chrislusf853701cb6b13
diff --git a/go/storage/needle_read_write.go b/go/storage/needle_read_write.go
index 6925c04e02..24a2c45ed2 100644
--- a/go/storage/needle_read_write.go
+++ b/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]
diff --git a/go/topology/store_replicate.go b/go/topology/store_replicate.go
index da426e587b..c44877da1c 100644
--- a/go/topology/store_replicate.go
+++ b/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
}
diff --git a/go/weed/weed_server/volume_server_handlers_write.go b/go/weed/weed_server/volume_server_handlers_write.go
index db0272f653..a42bdf9bbe 100644
--- a/go/weed/weed_server/volume_server_handlers_write.go
+++ b/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 {