From c2aef0cf539ebd7a3d786c5389a7903f7634f7a5 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 13 Nov 2026 02:58:26 -0800 Subject: [PATCH] mount: test the periodic flush after a peer unlinks a hard link name Co-Authored-By: Claude Opus 5.5 --- weed/mount/weedfs_peer_unlink_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/weed/mount/weedfs_peer_unlink_test.go b/weed/mount/weedfs_peer_unlink_test.go index 6886545fc3..be63c7abde 100644 --- a/weed/mount/weedfs_peer_unlink_test.go +++ b/weed/mount/weedfs_peer_unlink_test.go @@ -132,3 +132,22 @@ func TestPeerUnlinkLastNameKeepsHandleDeleted(t *testing.T) { t.Fatal("a peer unlinking the only name did not mark the handle deleted") } } + +// The periodic metadata flush publishes through the survivor as well. +func TestPeerUnlinkedAliasKeepsPeriodicFlushPublishing(t *testing.T) { + wfs, fake, fh, inode := openLinkTestFile(t) + linkInRoot(t, wfs, inode, "final") + peerUnlink(t, wfs, fake, "tmp") + fh.UpdateEntry(func(e *filer_pb.Entry) { + e.Chunks = append(e.Chunks, linkHandleChunk(2, 100)) + e.Attributes.FileSize = 200 + }) + fh.dirtyMetadata = true + if err := wfs.flushFileMetadata(fh); err != nil { + t.Fatalf("periodic flush after the peer unlink: %v", err) + } + wantStored(t, fake, "final", 2, 1) + if fake.stored("tmp") != nil { + t.Fatal("the periodic flush recreated tmp") + } +}