diff --git a/pkg/local_object_storage/metabase/exists.go b/pkg/local_object_storage/metabase/exists.go index 5d6b74669e..d18b07cdd0 100644 --- a/pkg/local_object_storage/metabase/exists.go +++ b/pkg/local_object_storage/metabase/exists.go @@ -105,12 +105,13 @@ func (db *DB) exists(tx *bbolt.Tx, addr oid.Address) (exists bool, err error) { // * 1 if object with GC mark; // * 2 if object is covered with tombstone. func inGraveyard(tx *bbolt.Tx, addr oid.Address) uint8 { + graveyardBkt := tx.Bucket(graveyardBucketName) + garbageBkt := tx.Bucket(garbageBucketName) addrKey := addressKey(addr) - return inGraveyardWithKey(tx, addrKey) + return inGraveyardWithKey(addrKey, graveyardBkt, garbageBkt) } -func inGraveyardWithKey(tx *bbolt.Tx, addrKey []byte) uint8 { - graveyard := tx.Bucket(graveyardBucketName) +func inGraveyardWithKey(addrKey []byte, graveyard, garbageBCK *bbolt.Bucket) uint8 { if graveyard == nil { // incorrect metabase state, does not make // sense to check garbage bucket @@ -119,7 +120,6 @@ func inGraveyardWithKey(tx *bbolt.Tx, addrKey []byte) uint8 { val := graveyard.Get(addrKey) if val == nil { - garbageBCK := tx.Bucket(garbageBucketName) if garbageBCK == nil { // incorrect node state return 0 diff --git a/pkg/local_object_storage/metabase/list.go b/pkg/local_object_storage/metabase/list.go index 3344f86b07..a690f7a866 100644 --- a/pkg/local_object_storage/metabase/list.go +++ b/pkg/local_object_storage/metabase/list.go @@ -178,6 +178,9 @@ func selectNFromBucket(tx *bbolt.Tx, addrRaw := make([]byte, len(prefix)+44) copy(addrRaw, prefix) + graveyardBkt := tx.Bucket(graveyardBucketName) + garbageBkt := tx.Bucket(garbageBucketName) + for ; k != nil; k, _ = c.Next() { if count >= limit { break @@ -190,7 +193,7 @@ func selectNFromBucket(tx *bbolt.Tx, offset = k addrRaw = append(addrRaw[:len(prefix)], k...) - if inGraveyardWithKey(tx, addrRaw) > 0 { + if inGraveyardWithKey(addrRaw, graveyardBkt, garbageBkt) > 0 { continue }