metabase: Delete GC marks #927

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:fix/gc_mark_delete into master 2024-01-24 19:00:47 +00:00
2 changed files with 43 additions and 0 deletions

View file

@ -264,6 +264,7 @@ func (db *DB) delete(tx *bbolt.Tx, addr oid.Address, refCounter referenceCounter
return deleteSingleResult{}, err
}
addrKey = addressKey(addr, key)
// remove record from the garbage bucket
if garbageBKT != nil {
err := garbageBKT.Delete(addrKey)

View file

@ -140,6 +140,48 @@ func TestExpiredObject(t *testing.T) {
})
}
func TestDelete(t *testing.T) {
db := newDB(t, meta.WithEpochState(epochState{currEpoch}))
defer func() { require.NoError(t, db.Close()) }()
cnr := cidtest.ID()
for i := 0; i < 10; i++ {
obj := testutil.GenerateObjectWithCID(cnr)
var prm meta.PutPrm
prm.SetObject(obj)
prm.SetStorageID([]byte("0/0"))
_, err := db.Put(context.Background(), prm)
require.NoError(t, err)
var inhumePrm meta.InhumePrm
inhumePrm.SetAddresses(object.AddressOf(obj))
_, err = db.Inhume(context.Background(), inhumePrm)
require.NoError(t, err)
}
var addrs []oid.Address
var iprm meta.GarbageIterationPrm
iprm.SetHandler(func(o meta.GarbageObject) error {
addrs = append(addrs, o.Address())
return nil
})
require.NoError(t, db.IterateOverGarbage(context.Background(), iprm))
require.Equal(t, 10, len(addrs))
var deletePrm meta.DeletePrm
deletePrm.SetAddresses(addrs...)
_, err := db.Delete(context.Background(), deletePrm)
require.NoError(t, err)
addrs = nil
iprm.SetHandler(func(o meta.GarbageObject) error {
addrs = append(addrs, o.Address())
return nil
})
require.NoError(t, db.IterateOverGarbage(context.Background(), iprm))
require.Equal(t, 0, len(addrs))
}
func metaDelete(db *meta.DB, addrs ...oid.Address) error {
var deletePrm meta.DeletePrm
deletePrm.SetAddresses(addrs...)