mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
filer: check descendants before an unlisted bucket drop
A non-recursive delete of an unmarked bucket on a drop-capable store swept children nothing had listed, swallowing entries under legal hold or retention. Walk the subtree for locks before the store drop, the same check the recursive preflight already runs.
This commit is contained in:
1 parent
876e98ff15
commit
15ac3500a3
2 files changed
+29
No files matched your search
@@ -428,6 +428,14 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
||||
// a non-recursive delete already proved the folder empty above, so sweeping the
|
||||
// children now can only remove entries that raced in after that listing
|
||||
if isRecursive || !listedChildren {
|
||||
if !listedChildren && !isRecursive && !isFromOtherCluster {
|
||||
// A bucket dropped whole sweeps children nothing has listed; a
|
||||
// recursive caller already walked them in the preflight, but a
|
||||
// non-recursive one has not.
|
||||
if lockErr := f.lockedDescendantError(ctx, entry); lockErr != nil {
|
||||
return lockErr
|
||||
}
|
||||
}
|
||||
if storeDeletionErr := f.Store.DeleteFolderChildren(ctx, entry.FullPath); storeDeletionErr != nil {
|
||||
return fmt.Errorf("filer store delete: %w", storeDeletionErr)
|
||||
}
|
||||
|
||||
@@ -338,6 +338,27 @@ func TestDeleteUnmarkedBucketOnDropCapableStoreRefusesLockedObject(t *testing.T)
|
||||
require.NotNil(t, store.getEntry("/buckets/b/held.bin"), "an unmarked bucket drop must not swallow the locked object")
|
||||
}
|
||||
|
||||
// A non-recursive delete of an unmarked bucket never lists the children the
|
||||
// store drops, so the sweep itself must check them for locks first.
|
||||
func TestDeleteUnmarkedBucketNonRecursiveRefusesLockedObject(t *testing.T) {
|
||||
store := newStubFilerStore()
|
||||
f := newTestFiler(t, store, NewFilerRemoteStorage())
|
||||
f.DirBucketsPath = "/buckets"
|
||||
f.Store = NewFilerStoreWrapper(&bucketDropStore{store})
|
||||
ctx := context.Background()
|
||||
|
||||
require.NoError(t, f.CreateEntry(ctx, &Entry{FullPath: "/buckets/b", Attr: Attr{Mode: os.ModeDir | 0755}}, nil, false, false, nil, true, 255))
|
||||
require.NoError(t, f.CreateEntry(ctx, &Entry{
|
||||
FullPath: "/buckets/b/held.bin",
|
||||
Attr: Attr{Mode: 0644},
|
||||
Extended: map[string][]byte{s3_constants.ExtLegalHoldKey: []byte("ON")},
|
||||
}, nil, false, false, nil, true, 255))
|
||||
|
||||
err := f.DeleteEntryMetaAndData(ctx, "/buckets/b", false, true, true, false, nil, 0)
|
||||
require.ErrorIs(t, err, ErrEntryLocked)
|
||||
require.NotNil(t, store.getEntry("/buckets/b/held.bin"), "a non-recursive unmarked bucket drop must not swallow the locked object")
|
||||
}
|
||||
|
||||
// An expired retention no longer locks: the delete proceeds normally.
|
||||
func TestDeleteEntryAllowsExpiredRetention(t *testing.T) {
|
||||
store := newStubFilerStore()
|
||||
|
||||
Reference in new issue
Block a user