[#1175] metabase: Implement LOCK operation

Implement `DB.Lock` method which marks list of the objects as locked by
another object. Only regular objects can be locked.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-02-15 14:35:13 +03:00 committed by LeL
parent 14d27455f3
commit 9f13674a10
4 changed files with 169 additions and 17 deletions

View file

@ -88,7 +88,7 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
addr.SetObjectID(id)
return h(&ExpiredObject{
typ: objectType(tx, cnrID, idKey),
typ: firstIrregularObjectType(tx, *cnrID, idKey),
addr: addr,
})
})
@ -102,17 +102,6 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
return err
}
func objectType(tx *bbolt.Tx, cid *cid.ID, oidBytes []byte) object.Type {
switch {
default:
return object.TypeRegular
case inBucket(tx, tombstoneBucketName(cid), oidBytes):
return object.TypeTombstone
case inBucket(tx, storageGroupBucketName(cid), oidBytes):
return object.TypeStorageGroup
}
}
// IterateCoveredByTombstones iterates over all objects in DB which are covered
// by tombstone with string address from tss.
//