forked from TrueCloudLab/frostfs-node
[#805] pilorama: Fix TreeDrop
* If treeID is empty then deleting buckets for cursor may get invalidated. So, buckets should be gathered before deleting. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
5cfb758e4e
commit
47286ebf32
1 changed files with 2 additions and 1 deletions
|
@ -1115,11 +1115,12 @@ func (t *boltForest) TreeDrop(ctx context.Context, cid cidSDK.ID, treeID string)
|
|||
c := tx.Cursor()
|
||||
prefix := make([]byte, 32)
|
||||
cid.Encode(prefix)
|
||||
for k, _ := c.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, _ = c.Next() {
|
||||
for k, _ := c.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, _ = c.Seek(prefix) {
|
||||
err := tx.DeleteBucket(k)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, _ = c.First() // rewind the cursor to the root page
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue