mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
filer.remote.sync: skip only a dropped local copy on a reshaped create
A stale RemoteEntry stamp (e.g. a synced file truncated to zero, which drops its chunks but keeps the stamp) still reads remote-only, so the HasData gate skipped the create and the truncated content never reached the new key. Gate on isDroppedLocalCopy instead: only an entry whose remote object still describes its size has nothing to send.
This commit is contained in:
1 parent
89f7618519
commit
c46819ca2d
2 files changed
+26
-3
No files matched your search
@@ -243,9 +243,9 @@ func processCreateEvent(
|
||||
return nil
|
||||
}
|
||||
// A create reshaped from a rename into the mount (mustSend) writes an empty
|
||||
// entry as a zero-byte object; a remote-only entry holds nothing local to
|
||||
// send and still skips.
|
||||
if !filer.HasData(message.NewEntry) && !(mustSend && !isRemoteOnly(message.NewEntry)) {
|
||||
// entry as a zero-byte object; a dropped local copy whose remote object
|
||||
// still describes it holds nothing local to send and still skips.
|
||||
if !filer.HasData(message.NewEntry) && !(mustSend && !isDroppedLocalCopy(message.NewEntry)) {
|
||||
return nil
|
||||
}
|
||||
glog.V(2).Infof("create: %+v", resp)
|
||||
|
||||
@@ -2216,6 +2216,29 @@ func TestRenameIntoMountWritesAnEmptyFile(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
// A stale stamp is not a dropped copy: truncating a synced file drops its
|
||||
// chunks and changes FileSize, but leaves the RemoteEntry behind, so
|
||||
// isRemoteOnly alone would skip the create and the truncated content would
|
||||
// never reach the new key.
|
||||
t.Run("a stale-stamped entry uploads its truncated content", func(t *testing.T) {
|
||||
stamp := &filer_pb.RemoteEntry{StorageName: "b2", RemoteETag: "abc", RemoteSize: 7, RemoteMtime: 1786096669, LastLocalSyncTsNs: 1786096669*1e9 + 1}
|
||||
entry := &filer_pb.Entry{Name: "empty.txt", Attributes: &filer_pb.FuseAttributes{Mtime: 1786096669, FileSize: 0}, RemoteEntry: stamp}
|
||||
if !isRemoteOnly(entry) {
|
||||
t.Fatal("precondition: the stale stamp still reads remote-only")
|
||||
}
|
||||
if isDroppedLocalCopy(entry) {
|
||||
t.Fatal("precondition: the stale object does not describe the entry")
|
||||
}
|
||||
remote := &recordingRemote{}
|
||||
filerClient := &stubFilerClient{entry: entry}
|
||||
if err := processCreateEvent(filerClient, filerClient, "", remote, mountedDir, mountLoc, renameIn(entry), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(remote.writes) != 1 || !proto.Equal(remote.writes[0], wantWrite) {
|
||||
t.Errorf("writes = %+v, want the new key %s written", remote.writes, remote_storage.FormatLocation(wantWrite))
|
||||
}
|
||||
})
|
||||
|
||||
// an ordinary create of an empty entry is unchanged: no object
|
||||
t.Run("a plain empty create still writes nothing", func(t *testing.T) {
|
||||
entry := &filer_pb.Entry{Name: "empty.txt", Attributes: &filer_pb.FuseAttributes{Mtime: 1786096669}}
|
||||
|
||||
Reference in new issue
Block a user