forked from TrueCloudLab/frostfs-node
[#698] blobovnicza: Store counter values
Blobovnicza initialization take a long time because of bucket Stat() call. So now blobovnicza stores counters in META bucket. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
5e8c08da3e
commit
e54dc3dc7c
8 changed files with 152 additions and 7 deletions
|
@ -51,7 +51,7 @@ func (b *Blobovnicza) Delete(ctx context.Context, prm DeletePrm) (DeleteRes, err
|
|||
var dataSize uint64
|
||||
|
||||
err := b.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||
return b.iterateAllDataBuckets(tx, func(lower, upper uint64, buck *bbolt.Bucket) (bool, error) {
|
||||
err := b.iterateAllDataBuckets(tx, func(lower, upper uint64, buck *bbolt.Bucket) (bool, error) {
|
||||
objData := buck.Get(addrKey)
|
||||
if objData == nil {
|
||||
// object is not in bucket => continue iterating
|
||||
|
@ -63,6 +63,21 @@ func (b *Blobovnicza) Delete(ctx context.Context, prm DeletePrm) (DeleteRes, err
|
|||
found = true
|
||||
return true, buck.Delete(addrKey)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if found {
|
||||
return updateMeta(tx, func(count, size uint64) (uint64, uint64) {
|
||||
if count > 0 {
|
||||
count--
|
||||
}
|
||||
if size >= sizeUpperBound {
|
||||
size -= sizeUpperBound
|
||||
}
|
||||
return count, size
|
||||
})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err == nil && !found {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue