mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
shell: fs.verify -restoreFrom holds one restored needle in memory at a time
Every checked needle of an entry was kept until the uploads, so a large file with many lost chunks could exhaust memory. The check now drops the bytes and each needle is read again just before its upload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e1671a4ad
commit
db13f03747
1 file changed
+14
-10
@@ -35,10 +35,8 @@ type restoreTarget struct {
|
||||
}
|
||||
|
||||
type restorableChunk struct {
|
||||
fileId string
|
||||
needle *needle.Needle
|
||||
chunk *filer_pb.FileChunk
|
||||
collection string
|
||||
manifest bool
|
||||
}
|
||||
|
||||
// restoreEntry copies the restorable missing chunks of an entry from the
|
||||
@@ -55,13 +53,13 @@ func (c *commandFsVerify) restoreEntry(path util.FullPath, attr *filer_pb.FuseAt
|
||||
continue
|
||||
}
|
||||
seen[fileId] = true
|
||||
n, collection, err := c.readRestorableNeedle(chunk)
|
||||
_, collection, err := c.readRestorableNeedle(chunk)
|
||||
if err != nil {
|
||||
fmt.Fprintf(c.writer, "not restorable %s chunk %s: %v\n", path, fileId, err)
|
||||
mayHold = mayHold || restoreSourceMayHold(err)
|
||||
continue
|
||||
}
|
||||
ready = append(ready, restorableChunk{fileId: fileId, needle: n, collection: collection, manifest: chunk.IsChunkManifest})
|
||||
ready = append(ready, restorableChunk{chunk: chunk, collection: collection})
|
||||
}
|
||||
if len(ready) == 0 {
|
||||
return false, mayHold
|
||||
@@ -94,12 +92,18 @@ func (c *commandFsVerify) restoreEntry(path util.FullPath, attr *filer_pb.FuseAt
|
||||
newFileIds := make(map[string]string)
|
||||
var uploaded []orphanedNeedle
|
||||
for _, r := range ready {
|
||||
fileId, err := c.uploadRestored(restoreTarget{path, r.collection, ttlSec}, r.needle.Data, r.needle.IsCompressed(), restoreMimeType(r.needle))
|
||||
// read again rather than held, so one needle at a time is in memory
|
||||
oldFileId := r.chunk.GetFileIdString()
|
||||
n, _, err := c.readRestorableNeedle(r.chunk)
|
||||
var fileId string
|
||||
if err == nil {
|
||||
fileId, err = c.uploadRestored(restoreTarget{path, r.collection, ttlSec}, n.Data, n.IsCompressed(), restoreMimeType(n))
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Fprintf(c.writer, "not restored %s chunk %s: %v\n", path, r.fileId, err)
|
||||
fmt.Fprintf(c.writer, "not restored %s chunk %s: %v\n", path, oldFileId, err)
|
||||
continue
|
||||
}
|
||||
newFileIds[r.fileId] = fileId
|
||||
newFileIds[oldFileId] = fileId
|
||||
uploaded = append(uploaded, newOrphanedNeedle(fileId))
|
||||
}
|
||||
if len(newFileIds) == 0 {
|
||||
@@ -170,8 +174,8 @@ func (c *commandFsVerify) restoreEntry(path util.FullPath, attr *filer_pb.FuseAt
|
||||
fmt.Fprintf(c.writer, "restored %s chunk %s -> %s\n", path, oldFileId, applied[oldFileId])
|
||||
}
|
||||
for _, r := range ready {
|
||||
if _, found := applied[r.fileId]; found && r.manifest {
|
||||
fmt.Fprintf(c.writer, "restored %s manifest %s: run fs.verify again to check the chunks it holds\n", path, r.fileId)
|
||||
if _, found := applied[r.chunk.GetFileIdString()]; found && r.chunk.IsChunkManifest {
|
||||
fmt.Fprintf(c.writer, "restored %s manifest %s: run fs.verify again to check the chunks it holds\n", path, r.chunk.GetFileIdString())
|
||||
}
|
||||
}
|
||||
return true, true
|
||||
|
||||
Reference in new issue
Block a user