forked from TrueCloudLab/frostfs-node
[#1658] meta: Do not check object expiration in counters
Do not perform operations that produce unused results in `syncCounter`. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
431e331373
commit
532c41ca05
2 changed files with 9 additions and 8 deletions
|
@ -83,8 +83,6 @@ func (db *DB) init(reset bool) error {
|
||||||
string(shardInfoBucket): {},
|
string(shardInfoBucket): {},
|
||||||
}
|
}
|
||||||
|
|
||||||
epoch := db.epochState.CurrentEpoch()
|
|
||||||
|
|
||||||
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||||
var err error
|
var err error
|
||||||
if !reset {
|
if !reset {
|
||||||
|
@ -108,7 +106,7 @@ func (db *DB) init(reset bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reset {
|
if !reset {
|
||||||
err = syncCounter(tx, epoch, false)
|
err = syncCounter(tx, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not sync object counter: %w", err)
|
return fmt.Errorf("could not sync object counter: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -132,10 +130,8 @@ func (db *DB) init(reset bool) error {
|
||||||
|
|
||||||
// SyncCounters forces to synchronize the object counters.
|
// SyncCounters forces to synchronize the object counters.
|
||||||
func (db *DB) SyncCounters() error {
|
func (db *DB) SyncCounters() error {
|
||||||
epoch := db.epochState.CurrentEpoch()
|
|
||||||
|
|
||||||
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||||
return syncCounter(tx, epoch, true)
|
return syncCounter(tx, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ func (db *DB) updateCounter(tx *bbolt.Tx, typ objectType, delta uint64, inc bool
|
||||||
//
|
//
|
||||||
// Does nothing if counters are not empty and force is false. If force is
|
// Does nothing if counters are not empty and force is false. If force is
|
||||||
// true, updates the counters anyway.
|
// true, updates the counters anyway.
|
||||||
func syncCounter(tx *bbolt.Tx, epoch uint64, force bool) error {
|
func syncCounter(tx *bbolt.Tx, force bool) error {
|
||||||
b, err := tx.CreateBucketIfNotExists(shardInfoBucket)
|
b, err := tx.CreateBucketIfNotExists(shardInfoBucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get shard info bucket: %w", err)
|
return fmt.Errorf("could not get shard info bucket: %w", err)
|
||||||
|
@ -123,13 +123,18 @@ func syncCounter(tx *bbolt.Tx, epoch uint64, force bool) error {
|
||||||
var phyCounter uint64
|
var phyCounter uint64
|
||||||
var logicCounter uint64
|
var logicCounter uint64
|
||||||
|
|
||||||
|
graveyardBKT := tx.Bucket(graveyardBucketName)
|
||||||
|
garbageBKT := tx.Bucket(garbageBucketName)
|
||||||
|
|
||||||
err = iteratePhyObjects(tx, func(cnr cid.ID, obj oid.ID) error {
|
err = iteratePhyObjects(tx, func(cnr cid.ID, obj oid.ID) error {
|
||||||
phyCounter++
|
phyCounter++
|
||||||
|
|
||||||
addr.SetContainer(cnr)
|
addr.SetContainer(cnr)
|
||||||
addr.SetObject(obj)
|
addr.SetObject(obj)
|
||||||
|
|
||||||
if st := objectStatus(tx, addr, epoch); st == 0 || st == 3 {
|
// check if an object is available: not with GCMark
|
||||||
|
// and not covered with a tombstone
|
||||||
|
if inGraveyardWithKey(addressKey(addr), graveyardBKT, garbageBKT) == 0 {
|
||||||
logicCounter++
|
logicCounter++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue