mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-16 08:45:22 +01:00
mount: let a rename remove its source at the source's own version (#10973)
* mount: let a rename remove its source at the source's own version
A rename stamps the source and takes the name away at the same log position,
so the removal reaches the meta cache carrying exactly the version the source
already records. The version gate read that as a write already reflected and
dropped it, while the destination half of the same event still applied -- the
source stayed cached beside the destination, and readdir and stat went on
serving a name the filer no longer had:
gate dropped removal of /winfsp-test-TestRenameOverExisting/src
eventTs=1787761708173717200 record=1787761708173717200
floor=1787761708173717200 tombstone=false
A removal asks a different question from a write. An entry still present at
exactly that version has the write reflected but not its removal, so only a
strictly newer record fences one out; a tombstone is the removal already
reflected and goes on fencing as before.
* mount: sweep a section's vanished name recorded at the snapshot
The refresh deletes the names its listing did not return, but asked the gate
whether a write at the snapshot was reflected. A name recorded at exactly that
version has the write reflected and not its removal, so it survived the sweep
and stayed cached until some later event happened to touch it.
Same reading as the rename source a commit earlier: the call site removes, so
it asks about a removal.
This commit is contained in:
1 parent
f5f1dcbd8c
commit
8dcdb70594
5 files changed
+158
-8
No files matched your search
@@ -927,3 +927,48 @@ func TestRenameAcrossSectionsCountsBoth(t *testing.T) {
|
||||
t.Fatal("the landing side's section should be invalidated")
|
||||
}
|
||||
}
|
||||
|
||||
// A refresh sweeps the names its listing did not return. One recorded at
|
||||
// exactly the snapshot has its write reflected but not its removal, so reading
|
||||
// the gate as a write left it cached for good.
|
||||
func TestSectionRefreshSweepsANameRecordedAtTheSnapshot(t *testing.T) {
|
||||
mc, _, _, _ := newTestMetaCache(t, map[util.FullPath]bool{"/": true, "/dir": true})
|
||||
defer mc.Shutdown()
|
||||
|
||||
buildSectionedDir(t, mc, util.FullPath("/dir"), 1000, []string{"m"})
|
||||
|
||||
const snapshotTsNs = 5000
|
||||
if err := mc.ApplyMetadataResponse(context.Background(), &filer_pb.SubscribeMetadataResponse{
|
||||
Directory: "/dir",
|
||||
EventNotification: &filer_pb.EventNotification{
|
||||
NewEntry: &filer_pb.Entry{
|
||||
Name: "b-vanish",
|
||||
Attributes: &filer_pb.FuseAttributes{Crtime: 1, Mtime: 1, FileMode: 0100644, FileSize: 3},
|
||||
},
|
||||
},
|
||||
TsNs: snapshotTsNs,
|
||||
}, SubscriberMetadataResponseApplyOptions); err != nil {
|
||||
t.Fatalf("seed at the snapshot version: %v", err)
|
||||
}
|
||||
|
||||
if err := mc.enqueueAndWait(context.Background(), metadataApplyRequest{
|
||||
kind: metadataSectionRefresh,
|
||||
buildPath: util.FullPath("/dir"),
|
||||
refresh: §ionRefresh{
|
||||
hi: "m",
|
||||
entries: []*filer.Entry{
|
||||
{
|
||||
FullPath: util.FullPath("/dir/b-keep"),
|
||||
Attr: filer.Attr{Crtime: time.Unix(1, 0), Mtime: time.Unix(2, 0), Mode: 0100644, FileSize: 7},
|
||||
},
|
||||
},
|
||||
snapshotTsNs: snapshotTsNs,
|
||||
},
|
||||
}); err != nil {
|
||||
t.Fatalf("refresh: %v", err)
|
||||
}
|
||||
|
||||
if entry, _, err := mc.FindEntry(context.Background(), util.FullPath("/dir/b-vanish")); err == nil && entry != nil {
|
||||
t.Error("a name the refresh did not list is still cached")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user